CMS 3D CMS Logo

GEMDQMSource.cc
Go to the documentation of this file.
9 
10 
14 
18 
21 
22 #include <string>
23 
24 //----------------------------------------------------------------------------------------------------
25 
27 {
28 public:
30  ~GEMDQMSource() override {};
31  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
32 protected:
33  void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override {};
34  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
35  void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
36  void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override {};
37  void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override {};
38  void endRun(edm::Run const& run, edm::EventSetup const& eSetup) override {};
39 
40 private:
42 
43  const GEMGeometry* initGeometry(edm::EventSetup const & iSetup);
44  int findVFAT(float min_, float max_, float x_, int roll_);
45 
47 
48  std::vector<GEMChamber> gemChambers_;
49 
50  std::unordered_map<UInt_t, MonitorElement*> recHitME_;
51  std::unordered_map<UInt_t, MonitorElement*> VFAT_vs_ClusterSize_;
52  std::unordered_map<UInt_t, MonitorElement*> StripsFired_vs_eta_;
53  std::unordered_map<UInt_t, MonitorElement*> rh_vs_eta_;
54 
55 };
56 
57 using namespace std;
58 using namespace edm;
59 
60 int GEMDQMSource::findVFAT(float min_, float max_, float x_, int roll_) {
61  float step = abs(max_-min_)/3.0;
62  if ( x_ < (min(min_,max_)+step) ) { return 8 - roll_;}
63  else if ( x_ < (min(min_,max_)+2.0*step) ) { return 16 - roll_;}
64  else { return 24 - roll_;}
65 }
66 
68  const GEMGeometry* GEMGeometry_ = nullptr;
69  try {
71  iSetup.get<MuonGeometryRecord>().get(hGeom);
72  GEMGeometry_ = &*hGeom;
73  }
75  edm::LogError("MuonGEMBaseValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
76  return nullptr;
77  }
78  return GEMGeometry_;
79 }
80 
82 {
83  tagRecHit_ = consumes<GEMRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitsInputLabel"));
84 }
85 
87 {
89  desc.add<edm::InputTag>("recHitsInputLabel", edm::InputTag("gemRecHits", ""));
90  descriptions.add("GEMDQMSource", desc);
91 }
92 
94 {
95  GEMGeometry_ = initGeometry(iSetup);
96  if ( GEMGeometry_ == nullptr) return ;
97 
98  const std::vector<const GEMSuperChamber*>& superChambers_ = GEMGeometry_->superChambers();
99  for (auto sch : superChambers_){
100  int n_lay = sch->nChambers();
101  for (int l=0;l<n_lay;l++){
102  gemChambers_.push_back(*sch->chamber(l+1));
103  }
104  }
105  ibooker.cd();
106  ibooker.setCurrentFolder("GEM/recHit");
107  for (auto ch : gemChambers_){
108  GEMDetId gid = ch.id();
109  string hName = "recHit_Gemini_"+to_string(gid.chamber())+"_la_"+to_string(gid.layer());
110  string hTitle = "recHit Gemini chamber : "+to_string(gid.chamber())+", layer : "+to_string(gid.layer());
111  recHitME_[ ch.id() ] = ibooker.book1D(hName, hTitle, 24,0,24);
112 
113  string hName_2 = "VFAT_vs_ClusterSize_Gemini_"+to_string(gid.chamber())+"_la_"+to_string(gid.layer());
114  string hTitle_2 = "VFAT vs ClusterSize Gemini chamber : "+to_string(gid.chamber())+", layer : "+to_string(gid.layer());
115  VFAT_vs_ClusterSize_[ ch.id() ] = ibooker.book2D(hName_2, hTitle_2, 9, 1, 10, 24, 0, 24);
116 
117  string hName_fired = "StripFired_Gemini_"+to_string(gid.chamber())+"_la_"+to_string(gid.layer());
118  string hTitle_fired = "StripsFired Gemini chamber : "+to_string(gid.chamber())+", layer : "+to_string(gid.layer());
119  StripsFired_vs_eta_[ ch.id() ] = ibooker.book2D(hName_fired, hTitle_fired, 384, 1, 385, 8, 1,9);
120 
121  string hName_rh = "recHit_x_Gemini_"+to_string(gid.chamber())+"_la_"+to_string(gid.layer());
122  string hTitle_rh = "recHit local x Gemini chamber : "+to_string(gid.chamber())+", layer : "+to_string(gid.layer());
123  rh_vs_eta_[ ch.id() ] = ibooker.book2D(hName_rh, hTitle_rh, 50, -25, 25, 8, 1,9);
124  }
125 }
126 
127 void GEMDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup)
128 {
129  const GEMGeometry* GEMGeometry_ = initGeometry(eventSetup);
130  if ( GEMGeometry_ == nullptr) return;
131 
133  event.getByToken( this->tagRecHit_, gemRecHits);
134  if (!gemRecHits.isValid()) {
135  edm::LogError("GEMDQMSource") << "GEM recHit is not valid.\n";
136  return ;
137  }
138  for (auto ch : gemChambers_){
139  GEMDetId cId = ch.id();
140  for(auto roll : ch.etaPartitions()){
141  GEMDetId rId = roll->id();
142  const auto& recHitsRange = gemRecHits->get(rId);
143  auto gemRecHit = recHitsRange.first;
144  for ( auto hit = gemRecHit; hit != recHitsRange.second; ++hit ) {
145  int nVfat = findVFAT(1.0, 385.0, hit->firstClusterStrip()+0.5*hit->clusterSize(), rId.roll());
146  recHitME_[ cId ]->Fill(nVfat);
147  rh_vs_eta_[ cId ]->Fill(hit->localPosition().x(), rId.roll());
148  VFAT_vs_ClusterSize_[ cId ]->Fill(hit->clusterSize(), nVfat);
149  for(int i = hit->firstClusterStrip(); i < (hit->firstClusterStrip() + hit->clusterSize()); i++){
150  StripsFired_vs_eta_[ cId ]->Fill(i, rId.roll());
151  }
152  }
153  }
154  }
155 }
156 
T getParameter(std::string const &) const
edm::EDGetToken tagRecHit_
Definition: GEMDQMSource.cc:38
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int findVFAT(float min_, float max_, float x_, int roll_)
Definition: GEMDQMSource.cc:60
const GEMGeometry * GEMGeometry_
Definition: GEMDQMSource.cc:46
int roll() const
Definition: GEMDetId.h:80
~GEMDQMSource() override
Definition: GEMDQMSource.cc:30
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: GEMDetId.h:74
std::unordered_map< UInt_t, MonitorElement * > VFAT_vs_ClusterSize_
Definition: GEMDQMSource.cc:51
std::unordered_map< UInt_t, MonitorElement * > StripsFired_vs_eta_
Definition: GEMDQMSource.cc:52
int layer() const
Layer id: each station have two layers of chambers: layer 1 is the inner chamber and layer 2 is the o...
Definition: GEMDetId.h:69
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) override
Definition: GEMDQMSource.cc:37
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
T min(T a, T b)
Definition: MathUtil.h:58
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
const GEMGeometry * initGeometry(edm::EventSetup const &iSetup)
Definition: GEMDQMSource.cc:67
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEMDQMSource.cc:86
std::unordered_map< UInt_t, MonitorElement * > recHitME_
Definition: GEMDQMSource.cc:50
const std::vector< const GEMSuperChamber * > & superChambers() const
Return a vector of all GEM super chambers.
Definition: GEMGeometry.cc:55
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
std::unordered_map< UInt_t, MonitorElement * > rh_vs_eta_
Definition: GEMDQMSource.cc:53
const T & get() const
Definition: EventSetup.h:58
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: GEMDQMSource.cc:33
GEMDQMSource(const edm::ParameterSet &cfg)
Definition: GEMDQMSource.cc:81
void add(std::string const &label, ParameterSetDescription const &psetDescription)
return(e1-e2)*(e1-e2)+dp *dp
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) override
Definition: GEMDQMSource.cc:36
HLT enums.
std::vector< GEMChamber > gemChambers_
Definition: GEMDQMSource.cc:48
step
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: GEMDQMSource.cc:38
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMDQMSource.cc:93
Definition: event.py:1
Definition: Run.h:43