CMS 3D CMS Logo

GEMDQMSource.cc
Go to the documentation of this file.
9 
13 
17 
20 
21 #include <string>
22 
23 //----------------------------------------------------------------------------------------------------
24 
25 class GEMDQMSource : public DQMEDAnalyzer {
26 public:
28  ~GEMDQMSource() override{};
29  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
30 
31 protected:
32  void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override{};
33  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
34  void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
35 
36 private:
38 
41 
44 
45  const GEMGeometry* initGeometry(edm::EventSetup const& iSetup);
46  int findVFAT(float min_, float max_, float x_, int roll_);
47 
49 
50  std::vector<GEMChamber> gemChambers_;
51 
52  std::unordered_map<UInt_t, MonitorElement*> recHitME_;
53  std::unordered_map<UInt_t, MonitorElement*> VFAT_vs_ClusterSize_;
54  std::unordered_map<UInt_t, MonitorElement*> StripsFired_vs_eta_;
55  std::unordered_map<UInt_t, MonitorElement*> rh_vs_eta_;
56  std::unordered_map<UInt_t, MonitorElement*> recGlobalPos;
57 };
58 
59 using namespace std;
60 using namespace edm;
61 
62 int GEMDQMSource::findVFAT(float min_, float max_, float x_, int roll_) {
63  float step = abs(max_ - min_) / 3.0;
64  if (x_ < (min(min_, max_) + step)) {
65  return 8 - roll_;
66  } else if (x_ < (min(min_, max_) + 2.0 * step)) {
67  return 16 - roll_;
68  } else {
69  return 24 - roll_;
70  }
71 }
72 
74  const GEMGeometry* GEMGeometry_ = nullptr;
75  try {
77  iSetup.get<MuonGeometryRecord>().get(hGeom);
78  GEMGeometry_ = &*hGeom;
80  edm::LogError("MuonGEMBaseValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
81  return nullptr;
82  }
83  return GEMGeometry_;
84 }
85 
87  tagRecHit_ = consumes<GEMRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitsInputLabel"));
88 
89  nIdxFirstStrip_ = cfg.getParameter<int>("idxFirstStrip");
90  nClusterSizeBinNum_ = cfg.getParameter<int>("ClusterSizeBinNum");
91 
92  fGlobXMin_ = cfg.getParameter<double>("global_x_bound_min");
93  fGlobXMax_ = cfg.getParameter<double>("global_x_bound_max");
94  fGlobYMin_ = cfg.getParameter<double>("global_y_bound_min");
95  fGlobYMax_ = cfg.getParameter<double>("global_y_bound_max");
96 }
97 
100  desc.add<edm::InputTag>("recHitsInputLabel", edm::InputTag("gemRecHits", ""));
101 
102  desc.add<int>("idxFirstStrip", 0);
103  desc.add<int>("ClusterSizeBinNum", 9);
104 
105  desc.add<double>("global_x_bound_min", -350);
106  desc.add<double>("global_x_bound_max", 350);
107  desc.add<double>("global_y_bound_min", -260);
108  desc.add<double>("global_y_bound_max", 260);
109 
110  descriptions.add("GEMDQMSource", desc);
111 }
112 
114  std::vector<GEMDetId> listLayerOcc;
115 
116  GEMGeometry_ = initGeometry(iSetup);
117  if (GEMGeometry_ == nullptr)
118  return;
119 
120  const std::vector<const GEMSuperChamber*>& superChambers_ = GEMGeometry_->superChambers();
121  for (auto sch : superChambers_) {
122  int n_lay = sch->nChambers();
123  for (int l = 0; l < n_lay; l++) {
124  Bool_t bExist = false;
125  for (const auto& ch : gemChambers_)
126  if (ch.id() == sch->chamber(l + 1)->id())
127  bExist = true;
128  if (bExist)
129  continue;
130 
131  gemChambers_.push_back(*sch->chamber(l + 1));
132  }
133  }
134 
135  ibooker.cd();
136  ibooker.setCurrentFolder("GEM/recHit");
137 
138  for (const auto& ch : gemChambers_) {
139  GEMDetId gid = ch.id();
140 
141  std::string strIdxName = "Gemini_" + to_string(gid.chamber()) + "_GE" + (gid.region() > 0 ? "p" : "m") +
142  to_string(gid.station()) + "_" + to_string(gid.layer());
143  std::string strIdxTitle = "GEMINIm" + to_string(gid.chamber()) + " in GE" + (gid.region() > 0 ? "+" : "-") +
144  to_string(gid.station()) + "/" + to_string(gid.layer());
145 
146  std::string strStId = (gid.region() > 0 ? "p" : "m") + std::to_string(gid.station());
147  std::string strStT = (gid.region() > 0 ? "+" : "-") + std::to_string(gid.station());
148 
149  std::string strLa = std::to_string(gid.layer());
150  std::string strCh = std::to_string(gid.chamber());
151 
152  string hName = "recHit_" + strIdxName;
153  string hTitle = "recHit " + strIdxTitle;
154  hTitle += ";VFAT;";
155  recHitME_[gid] = ibooker.book1D(hName, hTitle, 24, 0, 24);
156 
157  string hName_2 = "VFAT_vs_ClusterSize_" + strIdxName;
158  string hTitle_2 = "VFAT vs ClusterSize " + strIdxTitle;
159  hTitle_2 += ";Cluster size;VFAT";
160  VFAT_vs_ClusterSize_[gid] =
161  ibooker.book2D(hName_2, hTitle_2, nClusterSizeBinNum_, 1, nClusterSizeBinNum_ + 1, 24, 0, 24);
162 
163  string hName_fired = "StripFired_" + strIdxName;
164  string hTitle_fired = "StripsFired " + strIdxTitle;
165  hTitle_fired += ";Strip;iEta";
166  StripsFired_vs_eta_[gid] = ibooker.book2D(hName_fired, hTitle_fired, 384, 1, 385, 8, 1, 9);
167 
168  string hName_rh = "recHit_x_" + strIdxName;
169  string hTitle_rh = "recHit local x " + strIdxTitle;
170  hTitle_rh += ";Local x (cm);iEta";
171  rh_vs_eta_[gid] = ibooker.book2D(hName_rh, hTitle_rh, 50, -25, 25, 8, 1, 9);
172 
173  GEMDetId lid(gid.region(), gid.ring(), gid.station(), gid.layer(), 0, 0);
174  Int_t nIdxOcc = 0;
175 
176  for (; nIdxOcc < (Int_t)listLayerOcc.size(); nIdxOcc++)
177  if (listLayerOcc[nIdxOcc] == lid)
178  break;
179  if (nIdxOcc >= (Int_t)listLayerOcc.size())
180  listLayerOcc.push_back(lid);
181  }
182 
183  for (auto gid : listLayerOcc) {
184  std::string strIdxName =
185  std::string("GE") + (gid.region() > 0 ? "p" : "m") + to_string(gid.station()) + "_" + to_string(gid.layer());
186  std::string strIdxTitle =
187  std::string("GE") + (gid.region() > 0 ? "+" : "-") + to_string(gid.station()) + "/" + to_string(gid.layer());
188 
189  string hName_rh = "recHit_globalPos_Gemini_" + strIdxName;
190  string hTitle_rh = "recHit global position Gemini chamber : " + strIdxTitle;
191  hTitle_rh += ";Global X (cm);Global Y (cm)";
192  recGlobalPos[gid] = ibooker.book2D(hName_rh, hTitle_rh, 100, fGlobXMin_, fGlobXMax_, 100, fGlobYMin_, fGlobYMax_);
193  }
194 }
195 
196 void GEMDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) {
197  const GEMGeometry* GEMGeometry_ = initGeometry(eventSetup);
198  if (GEMGeometry_ == nullptr)
199  return;
200 
202  event.getByToken(this->tagRecHit_, gemRecHits);
203  if (!gemRecHits.isValid()) {
204  edm::LogError("GEMDQMSource") << "GEM recHit is not valid.\n";
205  return;
206  }
207  for (const auto& ch : gemChambers_) {
208  GEMDetId cId = ch.id();
209  for (auto roll : ch.etaPartitions()) {
210  GEMDetId rId = roll->id();
211  const auto& recHitsRange = gemRecHits->get(rId);
212  auto gemRecHit = recHitsRange.first;
213  for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) {
214  Int_t nIdxStrip = hit->firstClusterStrip() + 0.5 * hit->clusterSize() - nIdxFirstStrip_;
215  Int_t nVfat = 8 * ((Int_t)(nIdxStrip / (roll->nstrips() / 3)) + 1) - rId.roll(); // Strip:Start at 0
216  recHitME_[cId]->Fill(nVfat);
217  rh_vs_eta_[cId]->Fill(hit->localPosition().x(), rId.roll());
218  Int_t nCLSOverflow = (hit->clusterSize() <= nClusterSizeBinNum_ ? hit->clusterSize() : nClusterSizeBinNum_);
219  VFAT_vs_ClusterSize_[cId]->Fill(nCLSOverflow, nVfat);
220  for (int i = hit->firstClusterStrip(); i < (hit->firstClusterStrip() + hit->clusterSize()); i++) {
221  StripsFired_vs_eta_[cId]->Fill(i, rId.roll());
222  }
223 
224  GlobalPoint recHitGP = GEMGeometry_->idToDet(hit->gemId())->surface().toGlobal(hit->localPosition());
225  GEMDetId idLayer(rId.region(), rId.ring(), rId.station(), rId.layer(), 0, 0);
226  recGlobalPos[idLayer]->Fill(recHitGP.x(), recHitGP.y());
227  }
228  }
229  }
230 }
231 
mps_fire.i
i
Definition: mps_fire.py:428
GEMDQMSource::analyze
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
Definition: GEMDQMSource.cc:196
muonGEMRecHitPSet.gemRecHit
gemRecHit
Definition: muonGEMRecHitPSet.py:3
MessageLogger.h
GEMDetId::ring
constexpr int ring() const
Definition: GEMDetId.h:173
GEMRecHit.h
GEMDQMSource::nIdxFirstStrip_
int nIdxFirstStrip_
Definition: GEMDQMSource.cc:42
ESHandle.h
step
step
Definition: StallMonitor.cc:94
GEMDetId::layer
constexpr int layer() const
Definition: GEMDetId.h:187
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::Run
Definition: Run.h:45
min
T min(T a, T b)
Definition: MathUtil.h:58
GEMGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:25
GEMDetId::region
constexpr int region() const
Definition: GEMDetId.h:168
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
GEMDQMSource::StripsFired_vs_eta_
std::unordered_map< UInt_t, MonitorElement * > StripsFired_vs_eta_
Definition: GEMDQMSource.cc:54
DQMStore.h
edm::Handle< GEMRecHitCollection >
GEMDQMSource::findVFAT
int findVFAT(float min_, float max_, float x_, int roll_)
Definition: GEMDQMSource.cc:62
GEMDQMSource::nClusterSizeBinNum_
int nClusterSizeBinNum_
Definition: GEMDQMSource.cc:43
hit::x
double x
Definition: SiStripHitEffFromCalibTree.cc:89
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GEMDQMSource::tagRecHit_
edm::EDGetToken tagRecHit_
Definition: GEMDQMSource.cc:37
edm::ESHandle< GEMGeometry >
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
GEMDQMSource::GEMGeometry_
const GEMGeometry * GEMGeometry_
Definition: GEMDQMSource.cc:48
Point3DBase< float, GlobalTag >
GEMDQMSource::fGlobYMax_
float fGlobYMax_
Definition: GEMDQMSource.cc:40
GEMDQMSource::rh_vs_eta_
std::unordered_map< UInt_t, MonitorElement * > rh_vs_eta_
Definition: GEMDQMSource.cc:55
DQMEDAnalyzer.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
GEMDQMSource::initGeometry
const GEMGeometry * initGeometry(edm::EventSetup const &iSetup)
Definition: GEMDQMSource.cc:73
GEMDetId::chamber
constexpr int chamber() const
Definition: GEMDetId.h:180
MonitorElement.h
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
GEMDQMSource::fGlobXMax_
float fGlobXMax_
Definition: GEMDQMSource.cc:39
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
GEMDetId::roll
constexpr int roll() const
Definition: GEMDetId.h:191
GEMDetId
Definition: GEMDetId.h:18
GEMDQMSource::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMDQMSource.cc:113
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
ModuleDef.h
GEMDQMSource::fGlobXMin_
float fGlobXMin_
Definition: GEMDQMSource.cc:39
GEMDQMSource::recGlobalPos
std::unordered_map< UInt_t, MonitorElement * > recGlobalPos
Definition: GEMDQMSource.cc:56
GEMDQMSource::dqmBeginRun
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: GEMDQMSource.cc:32
GEMDQMSource::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEMDQMSource.cc:98
GEMRecHitCollection.h
edm::EventSetup
Definition: EventSetup.h:57
GEMDQMSource::fGlobYMin_
float fGlobYMin_
Definition: GEMDQMSource.cc:40
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::EDGetToken
Definition: EDGetToken.h:35
get
#define get
InputTag.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
looper.cfg
cfg
Definition: looper.py:297
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
GEMGeometry.h
std
Definition: JetResolutionObject.h:76
dqm::implementation::IBooker::book2D
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
EventSetup.h
GEMDigiCollection.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
edm::eventsetup::NoProxyException
Definition: NoProxyException.h:31
GEMDetId::station
constexpr int station() const
Definition: GEMDetId.h:176
GEMGeometry
Definition: GEMGeometry.h:24
GEMDQMSource::VFAT_vs_ClusterSize_
std::unordered_map< UInt_t, MonitorElement * > VFAT_vs_ClusterSize_
Definition: GEMDQMSource.cc:53
gemRecHits_cfi.gemRecHits
gemRecHits
Definition: gemRecHits_cfi.py:7
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
GEMDQMSource::gemChambers_
std::vector< GEMChamber > gemChambers_
Definition: GEMDQMSource.cc:50
MuonGeometryRecord.h
GEMDQMSource
Definition: GEMDQMSource.cc:25
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
GEMDQMSource::recHitME_
std::unordered_map< UInt_t, MonitorElement * > recHitME_
Definition: GEMDQMSource.cc:52
edm::InputTag
Definition: InputTag.h:15
GEMDQMSource::~GEMDQMSource
~GEMDQMSource() override
Definition: GEMDQMSource.cc:28
hit
Definition: SiStripHitEffFromCalibTree.cc:88
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
GEMDQMSource::GEMDQMSource
GEMDQMSource(const edm::ParameterSet &cfg)
Definition: GEMDQMSource.cc:86