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