CMS 3D CMS Logo

GEMBaseValidation.h
Go to the documentation of this file.
1 #ifndef Validation_MuonGEMHits_GEMBaseValidation_h
2 #define Validation_MuonGEMHits_GEMBaseValidation_h
3 
14 
16 
17 #include "TMath.h"
18 
20 public:
22  ~GEMBaseValidation() override = 0;
23  void analyze(const edm::Event& e, const edm::EventSetup&) override = 0;
24 
25 protected:
27  Int_t getDetOccBinX(Int_t chamber_id, Int_t layer_id);
28  Bool_t isMuonSimHit(const PSimHit&);
29 
31  Int_t region_id,
32  const char* name_prfix,
33  const char* title_prefix);
34 
35  template <typename T>
37  const T& key,
38  const char* name_prfix,
39  const char* title_prefix);
40 
41  template <typename T>
43  const T& key,
44  const char* name_prefix,
45  const char* title_prefix);
46 
47  template <typename T>
49  const T& key,
50  const char* name_prefix,
51  const char* title_prefix);
52 
53  template <typename T>
55  const T& key,
56  const GEMStation* station,
57  const char* name_prfix,
58  const char* title_prefix);
59 
60  template <typename T>
62  const T& key,
63  const char* name,
64  const char* title,
65  Int_t nbinsx,
66  Double_t xlow,
67  Double_t xup,
68  const char* x_title = "",
69  const char* y_title = "Entries");
70 
71  template <typename T>
73  const T& key,
74  const char* name,
75  const char* title,
76  Int_t nbinsx,
77  Double_t xlow,
78  Double_t xup,
79  Int_t nbinsy,
80  Double_t ylow,
81  Double_t yup,
82  const char* x_title = "",
83  const char* y_title = "");
84 
85  // NOTE Parameters
87  std::vector<Int_t> zr_occ_num_bins_;
88  std::vector<Double_t> zr_occ_range_;
89  std::vector<Double_t> eta_range_;
90  Bool_t detail_plot_;
91 
92  // NOTE Constants
93  const Int_t kMuonPDGId_ = 13;
94  const std::string kLogCategory_; // see member initializer list
95 };
96 
97 template <typename T>
99  const T& key,
100  const char* name_prefix,
101  const char* title_prefix) {
102  if (std::tuple_size<T>::value < 2) {
103  edm::LogError(kLogCategory_) << "Wrong T" << std::endl;
104  return nullptr;
105  }
106 
107  Int_t station_id = std::get<1>(key);
108 
109  auto name_suffix = GEMUtils::getSuffixName(key);
110  auto title_suffix = GEMUtils::getSuffixTitle(key);
111 
112  TString name = TString::Format("%s_occ_zr%s", name_prefix, name_suffix.Data());
113  TString title = TString::Format("%s ZR Occupancy :%s;|Z| #[cm];R [cm]", title_prefix, title_suffix.Data());
114 
115  // NOTE currently, only GE11 and GE21 are considered.
116  // Look Validation/MuonGEMHits/python/MuonGEMCommonParameters_cfi.py
117  UInt_t nbins_start = 2 * (station_id - 1);
118  Int_t nbinsx = zr_occ_num_bins_[nbins_start];
119  Int_t nbinsy = zr_occ_num_bins_[nbins_start + 1];
120 
121  // st1 xmin xmax, ymin, ymax | st2 xmin, xmax, ymin ymax
122  UInt_t range_start = 4 * (station_id - 1);
123  // absolute z axis
124  Double_t xlow = zr_occ_range_[range_start];
125  Double_t xup = zr_occ_range_[range_start + 1];
126  // R axis
127  Double_t ylow = zr_occ_range_[range_start + 2];
128  Double_t yup = zr_occ_range_[range_start + 3];
129 
130  return booker.book2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
131 }
132 
133 template <typename T>
135  const T& key,
136  const char* name_prefix,
137  const char* title_prefix) {
138  auto name_suffix = GEMUtils::getSuffixName(key);
139  auto title_suffix = GEMUtils::getSuffixTitle(key);
140  TString name = TString::Format("%s_occ_xy%s", name_prefix, name_suffix.Data());
141  TString title = TString::Format("%s XY Occupancy :%s;X [cm];Y [cm]", title_prefix, title_suffix.Data());
142  return booker.book2D(name, title, xy_occ_num_bins_, -360.0, 360.0, xy_occ_num_bins_, -360.0f, 360.0);
143 }
144 
145 template <typename T>
147  const T& key,
148  const char* name_prefix,
149  const char* title_prefix) {
150  auto name_suffix = GEMUtils::getSuffixName(key);
151  auto title_suffix = GEMUtils::getSuffixTitle(key);
152  TString name = TString::Format("%s_occ_polar%s", name_prefix, name_suffix.Data());
153  TString title = TString::Format("%s Polar Occupancy :%s", title_prefix, title_suffix.Data());
154  // TODO # of bins
155  // TODO the x-axis lies in the cnter of Ch1
156  dqm::impl::MonitorElement* me = booker.book2D(name, title, 108, -M_PI, M_PI, 108, 0.0, 360.0);
157  return me;
158 }
159 
160 template <typename T>
162  const T& key,
163  const GEMStation* station,
164  const char* name_prefix,
165  const char* title_prefix) {
166  auto name_suffix = GEMUtils::getSuffixName(key);
167  auto title_suffix = GEMUtils::getSuffixTitle(key);
168 
169  TString name = TString::Format("%s_occ_det%s", name_prefix, name_suffix.Data());
170  TString title = TString::Format("%s Occupancy for detector component :%s", title_prefix, title_suffix.Data());
171 
172  std::vector<const GEMSuperChamber*> superchambers = station->superChambers();
173 
174  Int_t num_superchambers = superchambers.size();
175  Int_t num_chambers = 0;
176  Int_t nbinsy = 0;
177  if (num_superchambers > 0) {
178  num_chambers = superchambers.front()->nChambers();
179  if (num_chambers > 0)
180  nbinsy = superchambers.front()->chambers().front()->nEtaPartitions();
181  }
182  Int_t nbinsx = num_superchambers * num_chambers;
183 
184  if (nbinsx <= 0)
185  nbinsx = 20; // Ensure histogram is not zero size
186  if (nbinsy <= 0)
187  nbinsy = 20;
188  auto hist = new TH2F(name, title, nbinsx, 1 - 0.5, nbinsx + 0.5, nbinsy, 1 - 0.5, nbinsy + 0.5);
189  hist->GetXaxis()->SetTitle("Chamber-Layer");
190  hist->GetYaxis()->SetTitle("Eta Partition");
191 
192  TAxis* x_axis = hist->GetXaxis();
193  for (Int_t chamber_id = 1; chamber_id <= num_superchambers; chamber_id++) {
194  for (Int_t layer_id = 1; layer_id <= num_chambers; layer_id++) {
195  Int_t bin = getDetOccBinX(chamber_id, layer_id);
196  TString label = TString::Format("C%dL%d", chamber_id, layer_id);
197  x_axis->SetBinLabel(bin, label);
198  }
199  }
200 
201  TAxis* y_axis = hist->GetYaxis();
202  for (Int_t bin = 1; bin <= nbinsy; bin++) {
203  y_axis->SetBinLabel(bin, TString::Itoa(bin, 10));
204  }
205 
206  return booker.book2D(name, hist);
207 }
208 
209 template <typename T>
211  const T& key,
212  const char* name,
213  const char* title,
214  Int_t nbinsx,
215  Double_t xlow,
216  Double_t xup,
217  const char* x_title,
218  const char* y_title) {
219  auto name_suffix = GEMUtils::getSuffixName(key);
220  auto title_suffix = GEMUtils::getSuffixTitle(key);
221  TString hist_name = TString::Format("%s%s", name, name_suffix.Data());
222  TString hist_title = TString::Format("%s :%s;%s;%s", title, title_suffix.Data(), x_title, y_title);
223  return booker.book1D(hist_name, hist_title, nbinsx, xlow, xup);
224 }
225 
226 template <typename T>
228  const T& key,
229  const char* name,
230  const char* title,
231  Int_t nbinsx,
232  Double_t xlow,
233  Double_t xup,
234  Int_t nbinsy,
235  Double_t ylow,
236  Double_t yup,
237  const char* x_title,
238  const char* y_title) {
239  auto name_suffix = GEMUtils::getSuffixName(key);
240  auto title_suffix = GEMUtils::getSuffixTitle(key);
241  TString hist_name = TString::Format("%s%s", name, name_suffix.Data());
242  TString hist_title = TString::Format("%s :%s;%s;%s", title, title_suffix.Data(), x_title, y_title);
243  return booker.book2D(hist_name, hist_title, nbinsx, xlow, xup, nbinsy, ylow, yup);
244 }
245 
246 #endif // Validation_MuonGEMHits_GEMBaseValidation_h
GEMBaseValidation::zr_occ_range_
std::vector< Double_t > zr_occ_range_
Definition: GEMBaseValidation.h:88
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
GEMBaseValidation::xy_occ_num_bins_
Int_t xy_occ_num_bins_
Definition: GEMBaseValidation.h:86
GEMBaseValidation::zr_occ_num_bins_
std::vector< Int_t > zr_occ_num_bins_
Definition: GEMBaseValidation.h:87
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
MessageLogger.h
GEMBaseValidation::detail_plot_
Bool_t detail_plot_
Definition: GEMBaseValidation.h:90
ESHandle.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
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
PSimHitContainer.h
DQMStore.h
GEMUtils::getSuffixName
TString getSuffixName(Int_t region_id)
Definition: GEMValidationUtils.cc:5
GEMValidationUtils.h
GEMBaseValidation::isMuonSimHit
Bool_t isMuonSimHit(const PSimHit &)
Definition: GEMBaseValidation.cc:32
GEMBaseValidation::bookZROccupancy
dqm::impl::MonitorElement * bookZROccupancy(DQMStore::IBooker &booker, Int_t region_id, const char *name_prfix, const char *title_prefix)
Definition: GEMBaseValidation.cc:34
GEMBaseValidation::~GEMBaseValidation
~GEMBaseValidation() override=0
Definition: GEMBaseValidation.cc:21
GEMBaseValidation::initGeometry
const GEMGeometry * initGeometry(const edm::EventSetup &)
Definition: GEMBaseValidation.cc:23
compare.hist
hist
Definition: compare.py:376
GEMStation
Definition: GEMStation.h:19
GEMBaseValidation::bookXYOccupancy
dqm::impl::MonitorElement * bookXYOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:134
EDGetToken.h
DQMEDAnalyzer.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
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
MonitorElement.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
GEMBaseValidation::GEMBaseValidation
GEMBaseValidation(const edm::ParameterSet &, std::string)
Definition: GEMBaseValidation.cc:10
GEMBaseValidation::eta_range_
std::vector< Double_t > eta_range_
Definition: GEMBaseValidation.h:89
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
GEMBaseValidation
Definition: GEMBaseValidation.h:19
edm::EventSetup
Definition: EventSetup.h:57
GEMBaseValidation::kMuonPDGId_
const Int_t kMuonPDGId_
Definition: GEMBaseValidation.h:93
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
GEMBaseValidation::analyze
void analyze(const edm::Event &e, const edm::EventSetup &) override=0
GEMGeometry.h
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
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
GEMUtils::getSuffixTitle
TString getSuffixTitle(Int_t region_id)
Definition: GEMValidationUtils.cc:34
GEMBaseValidation::bookPolarOccupancy
dqm::impl::MonitorElement * bookPolarOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:146
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
GEMGeometry
Definition: GEMGeometry.h:24
ParameterSet.h
PSimHit
Definition: PSimHit.h:15
MuonGeometryRecord.h
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:56
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
label
const char * label
Definition: PFTauDecayModeTools.cc:11
GEMBaseValidation::getDetOccBinX
Int_t getDetOccBinX(Int_t chamber_id, Int_t layer_id)
Definition: GEMBaseValidation.cc:30
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
GEMBaseValidation::kLogCategory_
const std::string kLogCategory_
Definition: GEMBaseValidation.h:94
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37