Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:28:09

0001 #include "Validation/MuonGEMHits/interface/GEMBaseValidation.h"
0002 #include "DataFormats/Common/interface/Handle.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h"
0005 
0006 #include <memory>
0007 
0008 using namespace dqm::impl;
0009 
0010 GEMBaseValidation::GEMBaseValidation(const edm::ParameterSet& ps, std::string log_category)
0011     : kLogCategory_(log_category) {
0012   pid_list_ = ps.getUntrackedParameter<std::vector<Int_t> >("pidList");
0013   zr_occ_num_bins_ = ps.getUntrackedParameter<std::vector<Int_t> >("ZROccNumBins");
0014   zr_occ_range_ = ps.getUntrackedParameter<std::vector<Double_t> >("ZROccRange");
0015   xy_occ_num_bins_ = ps.getUntrackedParameter<Int_t>("XYOccNumBins", 360);
0016   // TODO depends on the station.. for detail plots..
0017   eta_range_ = ps.getUntrackedParameter<std::vector<Double_t> >("EtaOccRange");
0018 
0019   detail_plot_ = ps.getParameter<Bool_t>("detailPlot");
0020 }
0021 
0022 GEMBaseValidation::~GEMBaseValidation() {}
0023 
0024 Int_t GEMBaseValidation::getDetOccBinX(Int_t num_layers, Int_t chamber_id, Int_t layer_id) {
0025   return num_layers * chamber_id + layer_id - num_layers;
0026 }
0027 
0028 Bool_t GEMBaseValidation::isMuonSimHit(const PSimHit& simhit) { return std::abs(simhit.particleType()) == kMuonPDGId_; }
0029 
0030 Float_t GEMBaseValidation::toDegree(Float_t radian) {
0031   Float_t degree = radian / M_PI * 180;
0032   if (degree < -5)
0033     return degree + 360;
0034   else
0035     return degree;
0036 }
0037 
0038 Int_t GEMBaseValidation::getPidIdx(Int_t pid) {
0039   return std::find(pid_list_.begin(), pid_list_.end(), pid) - pid_list_.begin();
0040 }
0041 
0042 MonitorElement* GEMBaseValidation::bookZROccupancy(DQMStore::IBooker& booker,
0043                                                    Int_t region_id,
0044                                                    const char* name_prefix,
0045                                                    const char* title_prefix) {
0046   auto name_suffix = GEMUtils::getSuffixName(region_id);
0047   auto title_suffix = GEMUtils::getSuffixTitle(region_id);
0048 
0049   TString name = TString::Format("%s_occ_zr%s", name_prefix, name_suffix.Data());
0050   TString title = TString::Format("%s ZR Occupancy :%s;|Z| [cm];R [cm]", title_prefix, title_suffix.Data());
0051 
0052   Double_t station0_xmin = zr_occ_range_[0];
0053   Double_t station0_xmax = zr_occ_range_[1];
0054   Double_t station1_xmin = zr_occ_range_[4];
0055   Double_t station1_xmax = zr_occ_range_[5];
0056   Double_t station2_xmin = zr_occ_range_[8];
0057   Double_t station2_xmax = zr_occ_range_[9];
0058 
0059   std::vector<Double_t> xbins_vector;
0060   for (Double_t i = station0_xmin - 1; i < station2_xmax + 1; i += 0.25) {
0061     if (i > station0_xmax + 1 and i < station1_xmin - 1)
0062       continue;
0063     if (i > station1_xmax + 1 and i < station2_xmin - 1)
0064       continue;
0065     xbins_vector.push_back(i);
0066   }
0067 
0068   Int_t nbinsx = xbins_vector.size() - 1;
0069 
0070   Int_t nbinsy = zr_occ_num_bins_[2];
0071   Double_t ylow = std::min(zr_occ_range_[2], std::min(zr_occ_range_[6], zr_occ_range_[10]));
0072   Double_t yup = std::max(zr_occ_range_[3], std::max(zr_occ_range_[7], zr_occ_range_[11]));
0073 
0074   auto hist = new TH2F(name, title, nbinsx, &xbins_vector[0], nbinsy, ylow, yup);
0075   return booker.book2D(name, hist);
0076 }