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