CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GEMDigiSource.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace edm;
5 
7  tagDigi_ = consumes<GEMDigiCollection>(cfg.getParameter<edm::InputTag>("digisInputLabel"));
8  lumiScalers_ = consumes<LumiScalersCollection>(
9  cfg.getUntrackedParameter<edm::InputTag>("lumiCollection", edm::InputTag("scalersRawToDigi")));
10  nBXMin_ = cfg.getParameter<int>("bxMin");
11  nBXMax_ = cfg.getParameter<int>("bxMax");
12 }
13 
16  desc.add<edm::InputTag>("digisInputLabel", edm::InputTag("muonGEMDigis", ""));
17  desc.addUntracked<std::string>("runType", "online");
18  desc.addUntracked<std::string>("logCategory", "GEMDigiSource");
19  desc.add<int>("bxMin", -10);
20  desc.add<int>("bxMax", 10);
21  descriptions.add("GEMDigiSource", desc);
22 }
23 
25  initGeometry(iSetup);
26  if (GEMGeometry_ == nullptr)
27  return;
28  loadChambers();
29 
30  strFolderMain_ = "GEM/Digis";
31 
32  fRadiusMin_ = 120.0;
33  fRadiusMax_ = 250.0;
34  float radS = -5.0 / 180 * M_PI;
35  float radL = 355.0 / 180 * M_PI;
36 
37  mapTotalDigi_layer_ = MEMap3Inf(this, "occ", "Digi Occupancy", 36, 0.5, 36.5, 24, -0.5, 24 - 0.5, "Chamber", "VFAT");
39  this, "occ_rphi", "Digi R-Phi Occupancy", 360, radS, radL, 8, fRadiusMin_, fRadiusMax_, "#phi (rad)", "R [cm]");
40  mapDigiOcc_ieta_ = MEMap3Inf(this, "occ_ieta", "Digi iEta Occupancy", 8, 0.5, 8.5, "iEta", "Number of fired digis");
42  MEMap3Inf(this, "occ_phi", "Digi Phi Occupancy", 72, -5, 355, "#phi (degree)", "Number of fired digis");
44  "digis_per_layer",
45  "Total number of digis per event for each layers",
46  50,
47  -0.5,
48  99.5,
49  "Number of fired digis",
50  "Events");
53  "digis_per_ieta",
54  "Total number of digis per event for each eta partitions",
55  50,
56  -0.5,
57  99.5,
58  "Number of fired digis",
59  "Events");
61 
62  mapBX_ = MEMap2Inf(this, "bx", "Digi Bunch Crossing", 21, nBXMin_ - 0.5, nBXMax_ + 0.5, "Bunch crossing");
63 
64  mapDigiOccPerCh_ = MEMap4Inf(this, "occ", "Digi Occupancy", 1, -0.5, 1.5, 1, 0.5, 1.5, "Digi", "iEta");
65 
68  mapBX_.TurnOff();
70  }
71 
76  }
77 
81  }
82 
86  }
87 
88  ibooker.cd();
90  GenerateMEPerChamber(ibooker);
91 }
92 
94  mapBX_.bookND(bh, key);
95 
96  return 0;
97 }
98 
101 
102  return 0;
103 }
104 
106  MEStationInfo& stationInfo = mapStationInfo_[key];
107 
108  int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
109 
111  mapTotalDigi_layer_.SetBinConfY(stationInfo.nMaxVFAT_, -0.5);
112  mapTotalDigi_layer_.bookND(bh, key);
115 
118  mapDigiWheel_layer_.SetNbinsX(nNumVFATPerEta * stationInfo.nNumChambers_);
120  mapDigiWheel_layer_.bookND(bh, key);
121 
123  mapDigiOcc_ieta_.bookND(bh, key);
125 
126  mapDigiOcc_phi_.SetBinLowEdgeX(stationInfo.fMinPhi_ * 180 / M_PI);
127  mapDigiOcc_phi_.SetBinHighEdgeX(stationInfo.fMinPhi_ * 180 / M_PI + 360);
128  mapDigiOcc_phi_.bookND(bh, key);
130 
131  return 0;
132 }
133 
135  ME3IdsKey key3 = key4Tokey3(key);
136  MEStationInfo& stationInfo = mapStationInfo_[key3];
137 
138  bh.getBooker()->setCurrentFolder(strFolderMain_ + "/occupancy_" + getNameDirLayer(key3));
139 
140  int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
141  int nNumCh = stationInfo.nNumDigi_;
142 
143  mapDigiOccPerCh_.SetBinConfX(nNumCh * nNumVFATPerEta, -0.5);
145  mapDigiOccPerCh_.bookND(bh, key);
147 
149 
150  return 0;
151 }
152 
153 void GEMDigiSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) {
155  event.getByToken(this->tagDigi_, gemDigis);
157  event.getByToken(lumiScalers_, lumiScalers);
158 
159  std::map<ME3IdsKey, Int_t> total_digi_layer;
160  std::map<ME3IdsKey, Int_t> total_digi_eta;
161  for (const auto& ch : gemChambers_) {
162  GEMDetId gid = ch.id();
163  ME2IdsKey key2{gid.region(), gid.station()};
164  ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
165  ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
166  std::map<Int_t, bool> bTagVFAT;
167  bTagVFAT.clear();
168  MEStationInfo& stationInfo = mapStationInfo_[key3];
169  const BoundPlane& surface = GEMGeometry_->idToDet(gid)->surface();
170  if (total_digi_layer.find(key3) == total_digi_layer.end())
171  total_digi_layer[key3] = 0;
172  for (auto iEta : ch.etaPartitions()) {
173  GEMDetId eId = iEta->id();
174  ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
175  if (total_digi_eta.find(key3IEta) == total_digi_eta.end())
176  total_digi_eta[key3IEta] = 0;
177  const auto& digis_in_det = gemDigis->get(eId);
178  for (auto d = digis_in_det.first; d != digis_in_det.second; ++d) {
179  // Filling of digi occupancy
180  Int_t nIdxVFAT = getVFATNumberByDigi(gid.station(), eId.ieta(), d->strip());
181  mapTotalDigi_layer_.Fill(key3, gid.chamber(), nIdxVFAT);
182 
183  // Filling of digi
184  mapDigiOcc_ieta_.Fill(key3, eId.ieta()); // Eta (partition)
185 
186  GlobalPoint digi_global_pos = surface.toGlobal(iEta->centreOfStrip(d->strip()));
187  Float_t fPhi = (Float_t)digi_global_pos.phi();
188  Float_t fPhiShift = restrictAngle(fPhi, stationInfo.fMinPhi_);
189  Float_t fPhiDeg = fPhiShift * 180.0 / M_PI;
190  mapDigiOcc_phi_.Fill(key3, fPhiDeg); // Phi
191 
192  // Filling of R-Phi occupancy
193  Float_t fR = fRadiusMin_ + (fRadiusMax_ - fRadiusMin_) * (eId.ieta() - 0.5) / stationInfo.nNumEtaPartitions_;
194  mapDigiWheel_layer_.Fill(key3, fPhiShift, fR);
195 
196  mapDigiOccPerCh_.Fill(key4Ch, d->strip(), eId.ieta()); // Per chamber
197 
198  // For total digis
199  total_digi_layer[key3]++;
200  total_digi_eta[key3IEta]++;
201 
202  // Filling of bx
203  Int_t nBX = std::min(std::max((Int_t)d->bx(), nBXMin_), nBXMax_); // For under/overflow
204  if (bTagVFAT.find(nIdxVFAT) == bTagVFAT.end()) {
205  mapBX_.Fill(key2, nBX);
206  }
207 
208  bTagVFAT[nIdxVFAT] = true;
209  }
210  }
211  }
212  for (auto [key, num_total_digi] : total_digi_layer)
213  mapTotalDigiPerEvtLayer_.Fill(key, num_total_digi);
214  for (auto [key, num_total_digi] : total_digi_eta)
215  mapTotalDigiPerEvtIEta_.Fill(key, num_total_digi);
216 }
217 
int ProcessWithMEMap2WithEta(BookingHelper &bh, ME3IdsKey key) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getUntrackedParameter(std::string const &, T const &) const
MEMapInfT< MEMap4Ids, ME4IdsKey > MEMap4Inf
Definition: GEMDQMBase.h:460
tuple cfg
Definition: looper.py:296
Int_t nRunType_
Definition: GEMDQMBase.h:516
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
MEMap3Inf mapTotalDigiPerEvtLayer_
Definition: GEMDigiSource.h:55
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
int getVFATNumberByDigi(const int, const int, const int)
Definition: GEMDQMBase.h:622
MEMapInfT< MEMap3Ids, ME3IdsKey > MEMap3Inf
Definition: GEMDQMBase.h:459
int ProcessWithMEMap2(BookingHelper &bh, ME2IdsKey key) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int SetLabelForChambers(K key, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:337
int initGeometry(edm::EventSetup const &iSetup)
Definition: GEMDQMBase.cc:31
std::tuple< Int_t, Int_t, Int_t, Int_t > ME4IdsKey
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:25
Float_t fRadiusMax_
Definition: GEMDigiSource.h:65
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
MEMap3Inf mapDigiOcc_ieta_
Definition: GEMDigiSource.h:53
MEMap4Inf mapDigiOccPerCh_
Definition: GEMDigiSource.h:59
MEMap3Inf mapDigiOcc_phi_
Definition: GEMDigiSource.h:54
int SetLabelForVFATs(K key, Int_t nNumEtaPartitions, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:359
std::map< ME3IdsKey, MEStationInfo > mapStationInfo_
Definition: GEMDQMBase.h:585
int loadChambers()
Definition: GEMDQMBase.cc:62
edm::EDGetTokenT< LumiScalersCollection > lumiScalers_
Definition: GEMDigiSource.h:49
void SetBinHighEdgeX(Double_t dXH)
Definition: GEMDQMBase.h:266
std::string strFolderMain_
Definition: GEMDigiSource.h:61
int Fill(K key, Double_t x)
Definition: GEMDQMBase.h:380
edm::EDGetToken tagDigi_
Definition: GEMDigiSource.h:47
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
MEMap3Inf mapTotalDigiPerEvtIEta_
Definition: GEMDigiSource.h:56
constexpr int ieta() const
Definition: GEMDetId.h:199
MEMap3Inf mapTotalDigi_layer_
Definition: GEMDigiSource.h:51
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MEMap2Inf mapBX_
Definition: GEMDigiSource.h:57
tuple d
Definition: ztail.py:151
void SetBinLowEdgeX(Double_t dXL)
Definition: GEMDQMBase.h:264
int GenerateMEPerChamber(DQMStore::IBooker &ibooker)
Definition: GEMDQMBase.cc:174
constexpr int region() const
Definition: GEMDetId.h:171
Float_t restrictAngle(const Float_t fTheta, const Float_t fStart)
Definition: GEMDQMBase.h:639
std::vector< GEMChamber > gemChambers_
Definition: GEMDQMBase.h:574
tuple key
prepare the HTCondor submission files and eventually submit them
MEMapInfT< MEMap2Ids, ME2IdsKey > MEMap2Inf
Definition: GEMDQMBase.h:458
void SetNbinsY(Int_t nBinsY)
Definition: GEMDQMBase.h:270
ParameterDescriptionBase * add(U const &iLabel, T const &value)
GEMDigiSource(const edm::ParameterSet &cfg)
Definition: GEMDigiSource.cc:6
#define M_PI
const GEMGeometry * GEMGeometry_
Definition: GEMDQMBase.h:571
int ProcessWithMEMap3WithChamber(BookingHelper &bh, ME4IdsKey key) override
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
void SetNoUnderOverflowBin()
Definition: GEMDQMBase.h:247
constexpr int chamber() const
Definition: GEMDetId.h:183
constexpr int layer() const
Definition: GEMDetId.h:190
int SetLabelForIEta(K key, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:357
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
constexpr int station() const
Definition: GEMDetId.h:179
void add(std::string const &label, ParameterSetDescription const &psetDescription)
DQMStore::IBooker * getBooker()
Definition: GEMDQMBase.h:94
std::string getNameDirLayer(ME3IdsKey key3)
Definition: GEMDQMBase.h:645
int bookND(BookingHelper &bh, K key)
Definition: GEMDQMBase.h:307
ME3IdsKey key4Tokey3(ME4IdsKey key)
Definition: GEMDQMBase.h:549
void SetNbinsX(Int_t nBinsX)
Definition: GEMDQMBase.h:262
std::tuple< Int_t, Int_t > ME2IdsKey
Float_t fRadiusMin_
Definition: GEMDigiSource.h:64
std::tuple< Int_t, Int_t, Int_t > ME3IdsKey
void SetBinConfX(Int_t nBins, Double_t dL=0.5, Double_t dH=-1048576.0)
Definition: GEMDQMBase.h:281
void SetBinConfY(Int_t nBins, Double_t dL=0.5, Double_t dH=-1048576.0)
Definition: GEMDQMBase.h:289
Definition: Run.h:45
MEMap3Inf mapDigiWheel_layer_
Definition: GEMDigiSource.h:52
int ProcessWithMEMap3(BookingHelper &bh, ME3IdsKey key) override