CMS 3D CMS Logo

GEMCoPadDigiValidation.cc
Go to the documentation of this file.
2 
4  : GEMBaseValidation(pset, "GEMCoPadDigiValidation") {
5  const auto& copad_pset = pset.getParameterSet("gemCoPadDigi");
6 
7  const auto& copad_tag = copad_pset.getParameter<edm::InputTag>("inputTag");
8  copad_token_ = consumes<GEMCoPadDigiCollection>(copad_tag);
9  geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
10  geomTokenBeginRun_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
11 
12  gem_bx_min_ = copad_pset.getParameter<int>("minBX");
13  gem_bx_max_ = copad_pset.getParameter<int>("maxBX");
14 }
15 
17  edm::Run const& run,
18  edm::EventSetup const& setup) {
19  const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_);
20 
21  // NOTE Occupancy
22  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/CoPad/Occupancy");
23 
24  for (const auto& region : gem->regions()) {
25  Int_t region_id = region->region();
26 
27  if (detail_plot_)
28  me_detail_occ_zr_[region_id] = bookZROccupancy(booker, region_id, "copad", "CoPad");
29 
30  for (const auto& station : region->stations()) {
31  Int_t station_id = station->station();
32  const auto& superChamberVec = station->superChambers();
33  if (superChamberVec.empty() || superChamberVec[0] == nullptr) {
34  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
35  << " and station = " << station_id;
36  continue;
37  }
38  const auto& chamberVec = superChamberVec[0]->chambers();
39  if (chamberVec.empty() || chamberVec[0] == nullptr) {
40  edm::LogError(kLogCategory_) << "Chambers missing or null for region, station, super chamber = (" << region_id
41  << ", " << station_id << ", " << superChamberVec[0]->id() << ")";
42  continue;
43  }
44  const auto& etaPartitionVec = chamberVec[0]->etaPartitions();
45  if (etaPartitionVec.empty() || etaPartitionVec[0] == nullptr) {
46  edm::LogError(kLogCategory_) << "Eta partition missing or null for region, station, super chamber, chamber = ("
47  << region_id << ", " << station_id << ", " << superChamberVec[0]->id() << ", "
48  << chamberVec[0]->id() << ")";
49  continue;
50  }
51  Int_t num_pads = etaPartitionVec[0]->npads();
52  ME2IdsKey key2{region_id, station_id};
53 
54  if (detail_plot_) {
55  me_detail_occ_xy_[key2] = bookXYOccupancy(booker, key2, "copad", "CoPad");
56 
57  me_detail_occ_phi_pad_[key2] = bookHist2D(booker,
58  key2,
59  "copad_occ_phi_pad",
60  "CoPad Occupancy",
61  280,
62  -M_PI,
63  M_PI,
64  num_pads / 2,
65  0,
66  num_pads,
67  "#phi [rad]",
68  "Pad number");
69 
71  booker, key2, "copad_occ_pad", "CoPad Ocupancy per pad number", num_pads, 0.5, num_pads + 0.5, "Pad number");
72 
73  me_detail_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "copad", "CoPad");
74  }
75  } // station loop
76  } // region loop
77 
78  // NOTE Bunch Crossing
79  if (detail_plot_) {
80  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/CoPad/BunchCrossing");
81 
82  for (const auto& region : gem->regions()) {
83  Int_t region_id = region->region();
84  for (const auto& station : region->stations()) {
85  Int_t station_id = station->station();
86  ME2IdsKey key2{region_id, station_id};
87 
88  me_detail_bx_[key2] =
89  bookHist1D(booker, key2, "copad_bx", "CoPad Bunch Crossing", 5, -2.5, 2.5, "Bunch crossing");
90  } // station loop
91  } // region loop
92  } // detail plot
93 }
94 
96 
98  const GEMGeometry* gem = &setup.getData(geomToken_);
99 
100  edm::Handle<GEMCoPadDigiCollection> copad_collection;
101  event.getByToken(copad_token_, copad_collection);
102  if (not copad_collection.isValid()) {
103  edm::LogError(kLogCategory_) << "Cannot get pads by token." << std::endl;
104  return;
105  }
106 
107  // GEMCoPadDigiCollection::DigiRangeIterator
108  for (const auto& copad_pair : *copad_collection) {
109  GEMDetId gemid = copad_pair.first;
110  const auto& range = copad_pair.second;
111 
112  Int_t region_id = gemid.region();
113  Int_t station_id = gemid.station();
114  Int_t ring_id = gemid.ring();
115  Int_t layer_id = gemid.layer();
116  Int_t chamber_id = gemid.chamber();
117  Int_t num_layers = gemid.nlayers();
118 
119  ME2IdsKey key2{region_id, station_id};
120 
121  for (auto digi = range.first; digi != range.second; ++digi) {
122  // GEM copads are stored per super chamber!
123  // layer_id = 0, roll_id = 0
124  GEMDetId super_chamber_id{region_id, ring_id, station_id, 0, chamber_id, 0};
125  Int_t roll_id = (*digi).roll();
126 
127  const GeomDet* geom_det = gem->idToDet(super_chamber_id);
128  if (geom_det == nullptr) {
129  edm::LogError(kLogCategory_) << super_chamber_id << " : This detId cannot be "
130  << "loaded from GEMGeometry // Original" << gemid << " station : " << station_id
131  << std::endl
132  << "Getting DetId failed. Discard this gem copad hit." << std::endl;
133  continue;
134  }
135 
136  const BoundPlane& surface = geom_det->surface();
137  const GEMSuperChamber* super_chamber = gem->superChamber(super_chamber_id);
138  if (super_chamber == nullptr) {
139  edm::LogError(kLogCategory_) << "Super chamber is null for super chamber ID = " << super_chamber_id;
140  continue;
141  }
142  Int_t pad1 = digi->pad(1);
143  Int_t pad2 = digi->pad(2);
144  Int_t bx1 = digi->bx(1);
145  Int_t bx2 = digi->bx(2);
146 
147  // Filtered using BX
148  if (bx1 < gem_bx_min_ or bx1 > gem_bx_max_)
149  continue;
150  if (bx2 < gem_bx_min_ or bx2 > gem_bx_max_)
151  continue;
152 
153  const Int_t padArray[] = {pad1, pad2};
154  LocalPoint lpArray[2];
155  int ptCounter = 0;
156  for (; ptCounter < 2; ++ptCounter) {
157  const GEMChamber* const chamber = super_chamber->chamber(ptCounter + 1); // Fetch chambers 1 and 2
158  if (chamber == nullptr) {
159  edm::LogError(kLogCategory_) << "Chamber " << (ptCounter + 1)
160  << " is null for super chamber = " << super_chamber_id;
161  break;
162  }
163  const GEMEtaPartition* const etaPartition = chamber->etaPartition(roll_id);
164  if (etaPartition == nullptr) {
165  edm::LogError(kLogCategory_) << "Eta partition " << roll_id << " is null for chamber, super chamber = ("
166  << (ptCounter + 1) << ", " << super_chamber_id << ")";
167  break;
168  }
169  lpArray[ptCounter] = etaPartition->centreOfPad(padArray[ptCounter]);
170  } // end for
171  if (ptCounter < 2) { // Broke out of "for" loop
172  edm::LogError(kLogCategory_) << "Skipping a digi due to bad chamber " << (ptCounter + 1);
173  continue;
174  }
175  const GlobalPoint& gp1 = surface.toGlobal(lpArray[0]);
176  const GlobalPoint& gp2 = surface.toGlobal(lpArray[1]);
177 
178  Float_t g_r1 = gp1.perp();
179  Float_t g_r2 = gp2.perp();
180 
181  Float_t g_z1 = gp1.z();
182  Float_t g_z2 = gp2.z();
183 
184  Float_t g_phi = gp1.phi();
185  Float_t g_x = gp1.x();
186  Float_t g_y = gp1.y();
187 
188  // Fill normal plots.
189 
190  Int_t bin_x = getDetOccBinX(num_layers, chamber_id, layer_id);
191 
192  // Fill detail plots.
193  if (detail_plot_) {
194  me_detail_occ_zr_[region_id]->Fill(std::fabs(g_z1), g_r1);
195  me_detail_occ_zr_[region_id]->Fill(std::fabs(g_z2), g_r2);
196  me_detail_occ_xy_[key2]->Fill(g_x, g_y);
197  me_detail_occ_det_[key2]->Fill(bin_x, roll_id);
198  me_detail_occ_det_[key2]->Fill(bin_x + 1, roll_id);
199  me_detail_occ_phi_pad_[key2]->Fill(g_phi, pad1);
200  me_detail_occ_pad_[key2]->Fill(pad1);
201  me_detail_bx_[key2]->Fill(bx1);
202  me_detail_bx_[key2]->Fill(bx2);
203  } // detail_plot_
204  } // loop over digis
205  } // loop over range iters
206 }
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
GEMBaseValidation::bookHist1D
dqm::impl::MonitorElement * bookHist1D(DQMStore::IBooker &booker, const T &key, const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, const char *x_title="", const char *y_title="Entries")
Definition: GEMBaseValidation.h:240
GEMDetId::ring
constexpr int ring() const
Definition: GEMDetId.h:176
GeomDet
Definition: GeomDet.h:27
GEMBaseValidation::detail_plot_
Bool_t detail_plot_
Definition: GEMBaseValidation.h:95
GEMSuperChamber
Definition: GEMSuperChamber.h:19
GEMCoPadDigiValidation::me_detail_occ_phi_pad_
MEMap2Ids me_detail_occ_phi_pad_
Definition: GEMCoPadDigiValidation.h:19
GEMDetId::layer
constexpr int layer() const
Definition: GEMDetId.h:190
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::Run
Definition: Run.h:45
GEMDetId::region
constexpr int region() const
Definition: GEMDetId.h:171
GEMBaseValidation::bookDetectorOccupancy
dqm::impl::MonitorElement * bookDetectorOccupancy(DQMStore::IBooker &booker, const T &key, const GEMStation *station, const char *name_prfix, const char *title_prefix)
Definition: GEMBaseValidation.h:168
relativeConstraints.station
station
Definition: relativeConstraints.py:67
GEMEtaPartition
Definition: GEMEtaPartition.h:12
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
GEMSuperChamber::chamber
const GEMChamber * chamber(GEMDetId id) const
Return the chamber corresponding to the given id.
Definition: GEMSuperChamber.cc:27
GEMCoPadDigiValidation::gem_bx_min_
int gem_bx_min_
Definition: GEMCoPadDigiValidation.h:30
GEMCoPadDigiValidation::gem_bx_max_
int gem_bx_max_
Definition: GEMCoPadDigiValidation.h:30
edm::Handle< GEMCoPadDigiCollection >
GEMCoPadDigiValidation::copad_token_
edm::EDGetTokenT< GEMCoPadDigiCollection > copad_token_
Definition: GEMCoPadDigiValidation.h:25
GEMDetId::nlayers
constexpr int nlayers() const
Definition: GEMDetId.h:213
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
GEMBaseValidation::bookZROccupancy
dqm::impl::MonitorElement * bookZROccupancy(DQMStore::IBooker &booker, Int_t region_id, const char *name_prfix, const char *title_prefix)
Definition: GEMBaseValidation.cc:42
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
alignCSCRings.ring_id
string ring_id
Definition: alignCSCRings.py:79
GEMCoPadDigiValidation::geomTokenBeginRun_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomTokenBeginRun_
Definition: GEMCoPadDigiValidation.h:27
GEMCoPadDigiValidation.h
GEMCoPadDigiValidation::me_detail_occ_xy_
MEMap2Ids me_detail_occ_xy_
Definition: GEMCoPadDigiValidation.h:18
GEMBaseValidation::bookXYOccupancy
dqm::impl::MonitorElement * bookXYOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:141
Point3DBase< float, LocalTag >
GEMCoPadDigiValidation::me_detail_bx_
MEMap2Ids me_detail_bx_
Definition: GEMCoPadDigiValidation.h:22
GEMBaseValidation::bookHist2D
dqm::impl::MonitorElement * bookHist2D(DQMStore::IBooker &booker, const T &key, const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char *x_title="", const char *y_title="")
Definition: GEMBaseValidation.h:257
GEMDetId::chamber
constexpr int chamber() const
Definition: GEMDetId.h:183
edm::ParameterSet
Definition: ParameterSet.h:47
GEMDetId
Definition: GEMDetId.h:18
GEMCoPadDigiValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GEMCoPadDigiValidation.cc:97
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
GEMBaseValidation
Definition: GEMBaseValidation.h:19
GEMCoPadDigiValidation::GEMCoPadDigiValidation
GEMCoPadDigiValidation(const edm::ParameterSet &)
Definition: GEMCoPadDigiValidation.cc:3
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
gem
Definition: AMC13Event.h:6
GEMCoPadDigiValidation::~GEMCoPadDigiValidation
~GEMCoPadDigiValidation() override
Definition: GEMCoPadDigiValidation.cc:95
GEMEtaPartition::centreOfPad
LocalPoint centreOfPad(int pad) const
Definition: GEMEtaPartition.cc:45
GEMChamber
Definition: GEMChamber.h:19
writedatasetfile.run
run
Definition: writedatasetfile.py:27
GEMCoPadDigiValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMCoPadDigiValidation.cc:16
GEMCoPadDigiValidation::geomToken_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
Definition: GEMCoPadDigiValidation.h:26
BoundPlane
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
GEMCoPadDigiValidation::me_detail_occ_det_
MEMap2Ids me_detail_occ_det_
Definition: GEMCoPadDigiValidation.h:17
GEMCoPadDigiValidation::me_detail_occ_zr_
MEMap1Ids me_detail_occ_zr_
Definition: GEMCoPadDigiValidation.h:16
dqm::implementation::IBooker
Definition: DQMStore.h:43
GEMDetId::station
constexpr int station() const
Definition: GEMDetId.h:179
GEMGeometry
Definition: GEMGeometry.h:24
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
GEMBaseValidation::getDetOccBinX
Int_t getDetOccBinX(Int_t num_layers, Int_t chamber_id, Int_t layer_id)
Definition: GEMBaseValidation.cc:24
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
GEMCoPadDigiValidation::me_detail_occ_pad_
MEMap2Ids me_detail_occ_pad_
Definition: GEMCoPadDigiValidation.h:20
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
GEMBaseValidation::kLogCategory_
const std::string kLogCategory_
Definition: GEMBaseValidation.h:99