CMS 3D CMS Logo

GEMDQMSourceDigi.cc
Go to the documentation of this file.
9 
14 
16 
19 
20 #include <string>
21 
22 //----------------------------------------------------------------------------------------------------
23 
25 {
26 public:
28  ~GEMDQMSourceDigi() override {};
29  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
30 protected:
31  void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override {};
32  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
33  void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
34  void endRun(edm::Run const& run, edm::EventSetup const& eSetup) override {};
35 
36 private:
38 
39  const GEMGeometry* initGeometry(edm::EventSetup const & iSetup);
40  int findVFAT(float min_, float max_, float x_, int roll_);
41 
43 
44  std::vector<GEMChamber> gemChambers_;
45 
46  std::unordered_map<UInt_t, MonitorElement*> Digi_2D_;
47  std::unordered_map<UInt_t, MonitorElement*> Digi_1D_;
48 
49 };
50 
51 using namespace std;
52 using namespace edm;
53 
54 int GEMDQMSourceDigi::findVFAT(float min_, float max_, float x_, int roll_) {
55  float step = max_/3;
56  if ( x_ < (min_+step) ) { return 8 - roll_;}
57  else if ( x_ < (min_+2*step) ) { return 16 - roll_;}
58  else { return 24 - roll_;}
59 }
60 
62  const GEMGeometry* GEMGeometry_ = nullptr;
63  try {
65  iSetup.get<MuonGeometryRecord>().get(hGeom);
66  GEMGeometry_ = &*hGeom;
67  }
69  edm::LogError("MuonGEMBaseValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
70  return nullptr;
71  }
72 
73  return GEMGeometry_;
74 }
75 
77 {
78  tagDigi_ = consumes<GEMDigiCollection>(cfg.getParameter<edm::InputTag>("digisInputLabel"));
79 }
80 
82 {
84  desc.add<edm::InputTag>("digisInputLabel", edm::InputTag("muonGEMDigis", ""));
85  descriptions.add("GEMDQMSourceDigi", desc);
86 }
87 
89 {
90  GEMGeometry_ = initGeometry(iSetup);
91  if ( GEMGeometry_ == nullptr) return ;
92 
93  const std::vector<const GEMSuperChamber*>& superChambers_ = GEMGeometry_->superChambers();
94  for (auto sch : superChambers_){
95  int n_lay = sch->nChambers();
96  for (int l=0;l<n_lay;l++){
97  gemChambers_.push_back(*sch->chamber(l+1));
98  }
99  }
100  ibooker.cd();
101  ibooker.setCurrentFolder("GEM/digi");
102  for (auto ch : gemChambers_){
103  GEMDetId gid = ch.id();
104  string hName_digi = "Digi_Strips_Gemini_"+to_string(gid.chamber())+"_l_"+to_string(gid.layer());
105  string hTitle_digi = "Digi Strip GEMINIm"+to_string(gid.chamber())+"l"+to_string(gid.layer());
106  Digi_2D_[ ch.id() ] = ibooker.book2D(hName_digi, hTitle_digi, 384, 1, 385, 8, 0.5,8.5);
107  Digi_1D_[ ch.id() ] = ibooker.book1D(hName_digi+"_VFAT", hTitle_digi+" VFAT", 24, 0, 24);
108  }
109 }
110 
112 {
113  const GEMGeometry* GEMGeometry_ = initGeometry(eventSetup);
114  if ( GEMGeometry_ == nullptr) return;
115 
117  event.getByToken( this->tagDigi_, gemDigis);
118  for (auto ch : gemChambers_){
119  GEMDetId cId = ch.id();
120  for(auto roll : ch.etaPartitions()){
121  GEMDetId rId = roll->id();
122  const auto& digis_in_det = gemDigis->get(rId);
123  for (auto d = digis_in_det.first; d != digis_in_det.second; ++d){
124  Digi_2D_[ cId ]->Fill(d->strip(), rId.roll());
125  Digi_1D_[ cId ]->Fill(findVFAT(1, roll->nstrips(), d->strip(), rId.roll()));
126  }
127  }
128  }
129 }
130 
T getParameter(std::string const &) const
int roll() const
Definition: GEMDetId.h:80
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: GEMDetId.h:74
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const GEMGeometry * initGeometry(edm::EventSetup const &iSetup)
return((rh^lh)&mask)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::vector< GEMChamber > gemChambers_
int findVFAT(float min_, float max_, float x_, int roll_)
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
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const GEMGeometry * GEMGeometry_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
T get() const
Definition: EventSetup.h:71
std::unordered_map< UInt_t, MonitorElement * > Digi_1D_
step
Definition: StallMonitor.cc:94
~GEMDQMSourceDigi() override
GEMDQMSourceDigi(const edm::ParameterSet &cfg)
edm::EDGetToken tagDigi_
Definition: event.py:1
Definition: Run.h:45
std::unordered_map< UInt_t, MonitorElement * > Digi_2D_