CMS 3D CMS Logo

GEMCoPadDigiValidation.cc
Go to the documentation of this file.
2 #include <TMath.h>
3 
5  InputTagToken_ = consumes<GEMCoPadDigiCollection>(cfg.getParameter<edm::InputTag>("CopadLabel"));
6  detailPlot_ = cfg.getParameter<bool>("detailPlot");
7  minBXGEM_ = cfg.getParameter<int>("minBXGEM");
8  maxBXGEM_ = cfg.getParameter<int>("maxBXGEM");
9 }
11  edm::Run const &Run,
12  edm::EventSetup const &iSetup) {
13  const GEMGeometry *GEMGeometry_ = initGeometry(iSetup);
14  if (GEMGeometry_ == nullptr)
15  return;
16  LogDebug("GEMCoPadDigiValidation") << "Geometry is acquired from MuonGeometryRecord\n";
17  ibooker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask");
18  LogDebug("GEMCoPadDigiValidation") << "ibooker set current folder\n";
19 
20  const double PI = TMath::Pi();
21 
22  int npadsGE11 =
23  GEMGeometry_->regions()[0]->stations()[0]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
24  int npadsGE21 = 0;
25  int nPads = 0;
26 
27  if (GEMGeometry_->regions()[0]->stations().size() > 1 &&
28  !GEMGeometry_->regions()[0]->stations()[1]->superChambers().empty()) {
29  npadsGE21 =
30  GEMGeometry_->regions()[0]->stations()[1]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
31  }
32 
33  for (auto &region : GEMGeometry_->regions()) {
34  int re = region->region();
35  TString title_suffix = getSuffixTitle(re);
36  TString histname_suffix = getSuffixName(re);
37  TString simpleZR_title = TString::Format("Copad ZR Occupancy%s; |Z|(cm) ; R(cm)", title_suffix.Data());
38  TString simpleZR_histname = TString::Format("copad_simple_zr%s", histname_suffix.Data());
39 
40  auto *simpleZR = getSimpleZR(ibooker, simpleZR_title, simpleZR_histname);
41  if (simpleZR != nullptr) {
42  theCoPad_simple_zr[simpleZR_histname.Hash()] = simpleZR;
43  }
44  for (auto &station : region->stations()) {
45  int st = station->station();
46  TString title_suffix2 = getSuffixTitle(re, st);
47  TString histname_suffix2 = getSuffixName(re, st);
48 
49  TString dcEta_title = TString::Format(
50  "Copad's occupancy for detector component %s; # of "
51  "sub-detector ;#eta-partition",
52  title_suffix2.Data());
53  TString dcEta_histname = TString::Format("copad_dcEta%s", histname_suffix2.Data());
54 
55  auto *dcEta = getDCEta(ibooker, station, dcEta_title, dcEta_histname);
56  if (dcEta != nullptr) {
57  theCoPad_dcEta[dcEta_histname.Hash()] = dcEta;
58  }
59  }
60 
61  if (detailPlot_) {
62  for (auto &region : GEMGeometry_->regions()) {
63  int re = region->region();
64  int region_num = (re + 1) / 2;
65  std::string name_prefix = getSuffixName(re);
66  std::string label_prefix = getSuffixTitle(re);
67  for (auto &station : region->stations()) {
68  int st = station->station();
69  int station_num = st - 1;
70 
71  if (st == 1)
72  nPads = npadsGE11;
73  else
74  nPads = npadsGE21;
75  name_prefix = getSuffixName(re, st);
76  label_prefix = getSuffixTitle(re, st);
77  theCSCCoPad_phipad[region_num][station_num] =
78  ibooker.book2D(("copad_dg_phipad" + name_prefix).c_str(),
79  ("Digi occupancy: " + label_prefix + "; phi [rad]; Pad number").c_str(),
80  280,
81  -PI,
82  PI,
83  nPads / 2,
84  0,
85  nPads);
86  theCSCCoPad[region_num][station_num] =
87  ibooker.book1D(("copad_dg" + name_prefix).c_str(),
88  ("Digi occupancy per pad number: " + label_prefix + ";Pad number; entries").c_str(),
89  nPads,
90  0.5,
91  nPads + 0.5);
92  theCSCCoPad_bx[region_num][station_num] =
93  ibooker.book1D(("copad_dg_bx" + name_prefix).c_str(),
94  ("Bunch crossing: " + label_prefix + "; bunch crossing ; entries").c_str(),
95  11,
96  -5.5,
97  5.5);
98  theCSCCoPad_zr[region_num][station_num] =
99  BookHistZR(ibooker, "copad_dg", "CoPad Digi", region_num, station_num);
100  theCSCCoPad_xy[region_num][station_num] =
101  BookHistXY(ibooker, "copad_dg", "CoPad Digi", region_num, station_num);
102  TString xy_name = TString::Format("copad_dg_xy%s_odd", name_prefix.c_str());
103  TString xy_title = TString::Format("Digi XY occupancy %s at odd chambers", label_prefix.c_str());
104  theCSCCoPad_xy_ch[xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360, 360, 360, -360, 360);
105  xy_name = TString::Format("copad_dg_xy%s_even", name_prefix.c_str());
106  xy_title = TString::Format("Digi XY occupancy %s at even chambers", label_prefix.c_str());
107  theCSCCoPad_xy_ch[xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360, 360, 360, -360, 360);
108  }
109  }
110  }
111  }
112 }
113 
115 
117  const GEMGeometry *GEMGeometry_;
118  try {
120  iSetup.get<MuonGeometryRecord>().get(hGeom);
121  GEMGeometry_ = &*hGeom;
123  edm::LogError("GEMCoPadDigiValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
124  return;
125  }
127  e.getByToken(InputTagToken_, gem_digis);
128  if (!gem_digis.isValid()) {
129  edm::LogError("GEMCoPadDigiValidation") << "Cannot get pads by token.";
130  return;
131  }
132 
133  for (GEMCoPadDigiCollection::DigiRangeIterator cItr = gem_digis->begin(); cItr != gem_digis->end(); cItr++) {
134  GEMDetId id = (*cItr).first;
135  int re = id.region();
136  int st = id.station();
137  int la = id.layer();
138  Short_t chamber = (Short_t)id.chamber();
140  // loop over digis of given roll
141  for (digiItr = (*cItr).second.first; digiItr != (*cItr).second.second; ++digiItr) {
142  // GEM copads are stored per super chamber!
143  GEMDetId schId = GEMDetId(re, id.ring(), st, 0, chamber, 0);
144  Short_t nroll = (*digiItr).roll();
145  LogDebug("GEMCoPadDigiValidation") << "schId : " << schId;
146  const GeomDet *gdet = GEMGeometry_->idToDet(schId);
147  if (gdet == nullptr) {
148  edm::LogError("GEMCoPadDigiValidation")
149  << schId << " : This detId cannot be loaded from GEMGeometry // Original" << id << " station : " << st;
150  edm::LogError("GEMCoPadDigiValidation") << "Getting DetId failed. Discard this gem copad hit. ";
151  continue;
152  }
153  const BoundPlane &surface = gdet->surface();
154  const GEMSuperChamber *superChamber = GEMGeometry_->superChamber(schId);
155  LogDebug("GEMCoPadDigiValidation") << " #pads in this partition : "
156  << superChamber->chamber(1)->etaPartition(1)->npads();
157 
158  Short_t pad1 = (Short_t)digiItr->pad(1);
159  Short_t pad2 = (Short_t)digiItr->pad(2);
160  Short_t bx1 = (Short_t)digiItr->bx(1);
161  Short_t bx2 = (Short_t)digiItr->bx(2);
162  LogDebug("GEMCoPadDigiValidation") << " copad #1 pad : " << pad1 << " bx : " << bx1;
163  LogDebug("GEMCoPadDigiValidation") << " copad #2 pad : " << pad2 << " bx : " << bx2;
164 
165  // Filtered using BX
166  if (bx1 < (Short_t)minBXGEM_ || bx1 > (Short_t)maxBXGEM_)
167  continue;
168  if (bx2 < (Short_t)minBXGEM_ || bx2 > (Short_t)maxBXGEM_)
169  continue;
170 
171  LocalPoint lp1 = superChamber->chamber(1)->etaPartition(nroll)->centreOfPad(pad1);
172  LocalPoint lp2 = superChamber->chamber(2)->etaPartition(nroll)->centreOfPad(pad2);
173 
174  GlobalPoint gp1 = surface.toGlobal(lp1);
175  GlobalPoint gp2 = surface.toGlobal(lp2);
176  Float_t g_r1 = (Float_t)gp1.perp();
177  Float_t g_r2 = (Float_t)gp2.perp();
178  Float_t g_z1 = (Float_t)gp1.z();
179  Float_t g_z2 = (Float_t)gp2.z();
180 
181  Float_t g_phi = (Float_t)gp1.phi();
182  Float_t g_x = (Float_t)gp1.x();
183  Float_t g_y = (Float_t)gp1.y();
184 
185  int region_num = 0;
186  if (re == -1)
187  region_num = 0;
188  else if (re == 1)
189  region_num = 1;
190  else {
191  edm::LogError("GEMCoPadDigiValidation") << "region : " << re << std::endl;
192  }
193  int binX = (chamber - 1) * 2 + la;
194  int binY = nroll;
195  int station_num = st - 1;
196 
197  // Fill normal plots.
198  TString histname_suffix = getSuffixName(re);
199  TString simple_zr_histname = TString::Format("copad_simple_zr%s", histname_suffix.Data());
200  theCoPad_simple_zr[simple_zr_histname.Hash()]->Fill(fabs(g_z1), g_r1);
201  theCoPad_simple_zr[simple_zr_histname.Hash()]->Fill(fabs(g_z2), g_r2);
202 
203  histname_suffix = getSuffixName(re, st);
204  TString dcEta_histname = TString::Format("copad_dcEta%s", histname_suffix.Data());
205  theCoPad_dcEta[dcEta_histname.Hash()]->Fill(binX, binY);
206  theCoPad_dcEta[dcEta_histname.Hash()]->Fill(binX + 1, binY);
207 
208  // Fill detail plots.
209  if (detailPlot_) {
210  theCSCCoPad_xy[region_num][station_num]->Fill(g_x, g_y);
211  theCSCCoPad_phipad[region_num][station_num]->Fill(g_phi, pad1);
212  theCSCCoPad[region_num][station_num]->Fill(pad1);
213  theCSCCoPad_bx[region_num][station_num]->Fill(bx1);
214  theCSCCoPad_bx[region_num][station_num]->Fill(bx2);
215  theCSCCoPad_zr[region_num][station_num]->Fill(g_z1, g_r1);
216  theCSCCoPad_zr[region_num][station_num]->Fill(g_z2, g_r2);
217  std::string name_prefix = getSuffixName(re, st);
218  TString hname;
219  if (chamber % 2 == 0) {
220  hname = TString::Format("copad_dg_xy%s_even", name_prefix.c_str());
221  } else {
222  hname = TString::Format("copad_dg_xy%s_odd", name_prefix.c_str());
223  }
224  theCSCCoPad_xy_ch[hname.Hash()]->Fill(g_x, g_y);
225  }
226  }
227  }
228 }
#define LogDebug(id)
const double Pi
T getParameter(std::string const &) const
const GEMChamber * chamber(GEMDetId id) const
Return the chamber corresponding to the given id.
MonitorElement * theCSCCoPad_zr[2][3]
T perp() const
Definition: PV3DBase.h:72
MonitorElement * BookHistZR(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int station_num, unsigned int layer_num=99)
std::unordered_map< UInt_t, MonitorElement * > theCSCCoPad_xy_ch
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
MonitorElement * getSimpleZR(DQMStore::IBooker &, TString, TString)
MonitorElement * BookHistXY(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int station_num, unsigned int layer_num=99)
std::string getSuffixTitle(int region, int station, int layer)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const GEMGeometry * initGeometry(const edm::EventSetup &)
void Fill(long long x)
std::string getSuffixName(int region, int station, int layer)
GEMCoPadDigiValidation(const edm::ParameterSet &)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
const std::vector< const GEMRegion * > & regions() const
Return a vector of all GEM regions.
Definition: GEMGeometry.cc:43
T z() const
Definition: PV3DBase.h:64
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
int npads() const
number of GEM-CSC trigger readout pads in partition
bool isValid() const
Definition: HandleBase.h:74
#define PI
Definition: QcdUeDQM.h:36
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: GEMDetId.h:53
const GEMSuperChamber * superChamber(GEMDetId id) const
Definition: GEMGeometry.cc:91
MonitorElement * theCSCCoPad_xy[2][3]
MonitorElement * theCSCCoPad[2][3]
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
MonitorElement * theCSCCoPad_phipad[2][3]
MonitorElement * theCSCCoPad_bx[2][3]
std::vector< DigiType >::const_iterator const_iterator
MonitorElement * getDCEta(DQMStore::IBooker &, const GEMStation *, TString, TString)
std::unordered_map< UInt_t, MonitorElement * > theCoPad_dcEta
void analyze(const edm::Event &e, const edm::EventSetup &) override
LocalPoint centreOfPad(int pad) const
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return the eta partition corresponding to the given id.
Definition: GEMChamber.cc:47
T get() const
Definition: EventSetup.h:71
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
T x() const
Definition: PV3DBase.h:62
std::unordered_map< UInt_t, MonitorElement * > theCoPad_simple_zr
Definition: Run.h:45