CMS 3D CMS Logo

GEMPadDigiClusterValidation.cc
Go to the documentation of this file.
2 #include <TMath.h>
3 
5  : GEMBaseValidation(pset, "GEMPadDigiClusterValidation") {
6  const auto& pad_cluster_pset = pset.getParameterSet("gemPadCluster");
7  const auto& pad_cluster_tag = pad_cluster_pset.getParameter<edm::InputTag>("inputTag");
8  pad_cluster_token_ = consumes<GEMPadDigiClusterCollection>(pad_cluster_tag);
9  geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
10  geomTokenBeginRun_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
11 }
12 
14  edm::Run const& Run,
15  edm::EventSetup const& setup) {
16  const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_);
17 
18  // NOTE Occupancy
19  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/PadCluster/Occupancy");
20  for (const auto& region : gem->regions()) {
21  Int_t region_id = region->region();
22 
23  me_occ_zr_.emplace(region_id, bookZROccupancy(booker, region_id, "pad", "Pad Cluster"));
24 
25  for (const auto& station : region->stations()) {
26  Int_t station_id = station->station();
27  ME2IdsKey key2{region_id, station_id};
28 
29  me_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "pad", "Pad Cluster");
30 
31  const auto& superChamberVec = station->superChambers();
32  if (superChamberVec.empty()) {
33  edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
34  << " and station = " << station_id;
35  continue;
36  }
37  const GEMSuperChamber* super_chamber = superChamberVec.front();
38  if (super_chamber == nullptr) {
39  edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
40  << " and station = " << station_id;
41  continue;
42  }
43  for (const auto& chamber : super_chamber->chambers()) {
44  Int_t layer_id = chamber->id().layer();
45  ME3IdsKey key3{region_id, station_id, layer_id};
46 
47  const auto& etaPartitionVec = chamber->etaPartitions();
48  if (etaPartitionVec.empty() || etaPartitionVec.front() == nullptr) {
50  << "Eta partition missing or null for region, station, super chamber, chamber = (" << region_id << ", "
51  << station_id << ", " << super_chamber->id() << ", " << chamber->id() << ")";
52  continue;
53  }
54  Int_t num_pads = etaPartitionVec.front()->npads();
55 
56  if (detail_plot_) {
57  me_detail_occ_xy_[key3] = bookXYOccupancy(booker, key3, "pad", "Pad Cluster");
58 
59  me_detail_occ_phi_pad_[key3] = bookHist2D(booker,
60  key3,
61  "occ_phi_pad",
62  "Pad Cluster Occupancy",
63  280,
64  -M_PI,
65  M_PI,
66  num_pads / 2,
67  0,
68  num_pads,
69  "#phi [rad]",
70  "Pad number");
71 
72  me_detail_occ_pad_[key3] =
73  bookHist1D(booker, key3, "occ_pad", "Pad Cluster Occupancy", num_pads, 0.5, num_pads + 0.5, "Pad number");
74  }
75  } // end loop over layer ids
76  } // end loop over station ids
77  } // end loop over region ids
78 
79  // NOTE Bunch Crossing
80  if (detail_plot_) {
81  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/PadCluster/BunchCrossing");
82 
83  for (const auto& region : gem->regions()) {
84  Int_t region_id = region->region();
85  for (const auto& station : region->stations()) {
86  Int_t station_id = station->station();
87 
88  const auto& superChamberVec = station->superChambers();
89  if (superChamberVec.empty()) {
90  edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
91  << " and station = " << station_id;
92  continue;
93  }
94  const GEMSuperChamber* super_chamber = superChamberVec.front();
95  if (super_chamber == nullptr) {
96  edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
97  << " and station = " << station_id;
98  continue;
99  }
100  for (const auto& chamber : super_chamber->chambers()) {
101  Int_t layer_id = chamber->id().layer();
102  ME3IdsKey key3(region_id, station_id, layer_id);
103  me_detail_bx_[key3] =
104  bookHist1D(booker, key3, "bx", "Pad Cluster Bunch Crossing", 5, -2.5, 2.5, "Bunch crossing");
105  } // chamber loop
106  } // station loop
107  } // region loop
108  } // detail plot
109 }
110 
112 
114  const GEMGeometry* gem = &setup.getData(geomToken_);
115 
117  event.getByToken(pad_cluster_token_, collection);
118  if (not collection.isValid()) {
119  edm::LogError(kLogCategory_) << "Cannot get pads by label GEMPadToken.";
120  return;
121  }
122 
123  for (auto range_iter = collection->begin(); range_iter != collection->end(); range_iter++) {
124  GEMDetId gemid = (*range_iter).first;
125  const auto& range = (*range_iter).second;
126 
127  if (gem->idToDet(gemid) == nullptr) {
128  edm::LogError(kLogCategory_) << "Getting DetId failed. Discard this gem pad hit. "
129  << "Maybe it comes from unmatched geometry." << std::endl;
130  continue;
131  }
132 
133  const GEMEtaPartition* roll = gem->etaPartition(gemid);
134  const BoundPlane& surface = roll->surface();
135 
136  Int_t region_id = gemid.region();
137  Int_t station_id = gemid.station();
138  Int_t layer_id = gemid.layer();
139  Int_t chamber_id = gemid.chamber();
140  Int_t roll_id = gemid.roll();
141 
142  ME2IdsKey key2(region_id, station_id);
143  ME3IdsKey key3(region_id, station_id, layer_id);
144 
145  for (auto digi = range.first; digi != range.second; ++digi) {
146  // ignore 16-partition GE2/1 pads
147  if (gemid.isGE21() and digi->nPartitions() == GEMPadDigiCluster::GE21SplitStrip)
148  continue;
149 
150  const auto& padsVec = digi->pads();
151  if (padsVec.empty()) {
152  edm::LogError(kLogCategory_) << "Pads missing for digi from GEM ID = " << gemid;
153  continue;
154  }
155  Int_t pad = padsVec[0];
156 
157  // bunch crossing
158  Int_t bx = digi->bx();
159 
160  const LocalPoint& local_pos = roll->centreOfPad(pad);
161  const GlobalPoint& global_pos = surface.toGlobal(local_pos);
162 
163  Float_t g_r = global_pos.perp();
164  Float_t g_phi = global_pos.phi();
165  Float_t g_x = global_pos.x();
166  Float_t g_y = global_pos.y();
167  Float_t g_abs_z = std::fabs(global_pos.z());
168 
169  me_occ_zr_[region_id]->Fill(g_abs_z, g_r);
170 
171  Int_t bin_x = getDetOccBinX(chamber_id, layer_id);
172  me_occ_det_[key2]->Fill(bin_x, roll_id);
173 
174  if (detail_plot_) {
175  me_detail_occ_xy_[key3]->Fill(g_x, g_y);
176  me_detail_occ_phi_pad_[key3]->Fill(g_phi, pad);
177  me_detail_occ_pad_[key3]->Fill(pad);
178  me_detail_bx_[key3]->Fill(bx);
179  } // detail_plot_
180  }
181  } // end loop over range iters
182 }
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
GEMDetId::isGE21
bool isGE21() const
Definition: GEMDetId.cc:11
GEMPadDigiClusterValidation::me_occ_det_
MEMap2Ids me_occ_det_
Definition: GEMPadDigiClusterValidation.h:15
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:210
GEMSuperChamber::chambers
const std::vector< const GEMChamber * > & chambers() const
Return the chambers in the super chamber.
Definition: GEMSuperChamber.cc:23
GEMPadDigiClusterValidation::GEMPadDigiClusterValidation
GEMPadDigiClusterValidation(const edm::ParameterSet &)
Definition: GEMPadDigiClusterValidation.cc:4
GEMBaseValidation::detail_plot_
Bool_t detail_plot_
Definition: GEMBaseValidation.h:88
GEMPadDigiClusterValidation::geomTokenBeginRun_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomTokenBeginRun_
Definition: GEMPadDigiClusterValidation.h:25
GEMSuperChamber
Definition: GEMSuperChamber.h:19
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
GEMDetId::region
constexpr int region() const
Definition: GEMDetId.h:168
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:161
relativeConstraints.station
station
Definition: relativeConstraints.py:67
GEMEtaPartition
Definition: GEMEtaPartition.h:12
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::Handle< GEMPadDigiClusterCollection >
GEMPadDigiClusterValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMPadDigiClusterValidation.cc:13
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
GEMPadDigiClusterValidation::pad_cluster_token_
edm::EDGetTokenT< GEMPadDigiClusterCollection > pad_cluster_token_
Definition: GEMPadDigiClusterValidation.h:23
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:27
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
GEMPadDigiClusterValidation::me_detail_bx_
MEMap3Ids me_detail_bx_
Definition: GEMPadDigiClusterValidation.h:21
GEMBaseValidation::bookXYOccupancy
dqm::impl::MonitorElement * bookXYOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:134
GEMPadDigiClusterValidation::me_occ_zr_
MEMap1Ids me_occ_zr_
Definition: GEMPadDigiClusterValidation.h:16
Point3DBase< float, LocalTag >
GEMPadDigiClusterValidation::me_detail_occ_phi_pad_
MEMap3Ids me_detail_occ_phi_pad_
Definition: GEMPadDigiClusterValidation.h:18
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:227
GEMPadDigiClusterValidation::geomToken_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
Definition: GEMPadDigiClusterValidation.h:24
GEMDetId::chamber
constexpr int chamber() const
Definition: GEMDetId.h:180
edm::ParameterSet
Definition: ParameterSet.h:47
GEMDetId::roll
constexpr int roll() const
Definition: GEMDetId.h:191
GEMDetId
Definition: GEMDetId.h:18
GEMPadDigiClusterValidation.h
GEMPadDigiClusterValidation::me_detail_occ_xy_
MEMap3Ids me_detail_occ_xy_
Definition: GEMPadDigiClusterValidation.h:17
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
GEMPadDigiClusterValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GEMPadDigiClusterValidation.cc:113
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
GEMBaseValidation
Definition: GEMBaseValidation.h:18
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
gem
Definition: AMC13Event.h:6
GEMEtaPartition::centreOfPad
LocalPoint centreOfPad(int pad) const
Definition: GEMEtaPartition.cc:45
BoundPlane
GEMPadDigiCluster::GE21SplitStrip
Definition: GEMPadDigiCluster.h:24
GEMPadDigiClusterValidation::~GEMPadDigiClusterValidation
~GEMPadDigiClusterValidation() override
Definition: GEMPadDigiClusterValidation.cc:111
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
ME3IdsKey
std::tuple< Int_t, Int_t, Int_t > ME3IdsKey
Definition: GEMValidationUtils.h:19
dqm::implementation::IBooker
Definition: DQMStore.h:43
GEMDetId::station
constexpr int station() const
Definition: GEMDetId.h:176
GEMGeometry
Definition: GEMGeometry.h:24
GEMPadDigiClusterValidation::me_detail_occ_pad_
MEMap3Ids me_detail_occ_pad_
Definition: GEMPadDigiClusterValidation.h:19
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
GEMSuperChamber::id
GEMDetId id() const
Return the GEMDetId of this super chamber.
Definition: GEMSuperChamber.cc:11
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
GEMBaseValidation::getDetOccBinX
Int_t getDetOccBinX(Int_t chamber_id, Int_t layer_id)
Definition: GEMBaseValidation.cc:23
GEMBaseValidation::kLogCategory_
const std::string kLogCategory_
Definition: GEMBaseValidation.h:92
Run