CMS 3D CMS Logo

GEMStripDigiValidation.cc
Go to the documentation of this file.
3 
4 #include <TMath.h>
5 #include <iomanip>
7 {
8  InputTagToken_ = consumes<GEMDigiCollection>(cfg.getParameter<edm::InputTag>("stripLabel"));
9  detailPlot_ = cfg.getParameter<bool>("detailPlot");
10 }
11 
13 
14  const GEMGeometry* GEMGeometry_ = initGeometry( iSetup) ;
15  if ( GEMGeometry_ == nullptr) return ;
16  LogDebug("GEMStripDigiValidation")<<"Geometry is acquired from MuonGeometryRecord\n";
17  ibooker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask");
18  LogDebug("GEMStripDigiValidation")<<"ibooker set current folder\n";
19 
20  LogDebug("GEMStripDigiValidation")<<"nregions set.\n";
21  LogDebug("GEMStripDigiValidation")<<"nstations set.\n";
22  int nstripsGE11 = 384;
23  int nstripsGE21 = 768;
24 
25  LogDebug("GEMStripDigiValidation")<<"Successfully binning set.\n";
26 
27 
28  int nstrips = 0;
29 
30 
31  for( auto& region : GEMGeometry_->regions() ){
32  int re = region->region();
33  TString title_suffix = getSuffixTitle( re );
34  TString histname_suffix = getSuffixName( re) ;
35  TString simpleZR_title = TString::Format("ZR Occupancy%s; |Z|(cm) ; R(cm)",title_suffix.Data());
36  TString simpleZR_histname = TString::Format("strip_simple_zr%s",histname_suffix.Data());
37 
38  auto* simpleZR = getSimpleZR(ibooker, simpleZR_title, simpleZR_histname);
39  if ( simpleZR != nullptr) {
40  theStrip_simple_zr[simpleZR_histname.Hash() ] = simpleZR;
41  }
42 
43  for( auto& station : region->stations()) {
44  int st = station->station();
45  TString title_suffix2 = getSuffixTitle( re, st ) ;
46  TString histname_suffix2 = getSuffixName( re, st) ;
47 
48  TString dcEta_title = TString::Format("Occupancy for detector component %s;;#eta-partition",title_suffix2.Data());
49  TString dcEta_histname = TString::Format("strip_dcEta%s",histname_suffix2.Data());
50 
51  auto* dcEta = getDCEta(ibooker, station, dcEta_title, dcEta_histname);
52  if ( dcEta != nullptr) {
53  theStrip_dcEta[ dcEta_histname.Hash() ] = dcEta;
54  }
55  }
56  }
57 
58  // Booking detail plot.
59  if ( detailPlot_ ) {
60  for( auto& region : GEMGeometry_->regions() ) {
61  for( auto& station : region->stations()) {
62  for( int la = 1 ; la <= 2 ; la++) {
63  int re = region->region();
64  int st = station->station();
65  int region_num = (re+1)/2;
66  int station_num = st-1;
67  int layer_num = la-1;
68 
69  if ( st ==1 ) nstrips = nstripsGE11;
70  else nstrips = nstripsGE21;
71  std::string name_prefix = getSuffixName( re, st, la);
72  std::string label_prefix = getSuffixTitle( re, st, la) ;
73  theStrip_phistrip[region_num][station_num][layer_num] = ibooker.book2D( ("strip_dg_phistrip"+name_prefix).c_str(), ("Digi occupancy: "+label_prefix+"; phi [rad];strip number").c_str(), 280, -TMath::Pi(), TMath::Pi(), nstrips/2,0,nstrips);
74  theStrip[region_num][station_num][layer_num] = ibooker.book1D( ("strip_dg"+name_prefix).c_str(), ("Digi occupancy per stip number: "+label_prefix+";strip number; entries").c_str(), nstrips,0.5,nstrips+0.5);
75  theStrip_bx[region_num][station_num][layer_num] = ibooker.book1D( ("strip_dg_bx"+name_prefix).c_str(), ("Bunch crossing: "+label_prefix+"; bunch crossing ; entries").c_str(), 11,-5.5,5.5);
76  theStrip_zr[region_num][station_num][layer_num] = BookHistZR(ibooker,"strip_dg","Strip Digi",region_num,station_num,layer_num);
77  theStrip_xy[region_num][station_num][layer_num] = BookHistXY(ibooker,"strip_dg","Strip Digi",region_num,station_num,layer_num);
78  TString xy_name = TString::Format("strip_dg_xy%s_odd",name_prefix.c_str());
79  TString xy_title = TString::Format("Digi XY occupancy %s at odd chambers",label_prefix.c_str());
80  theStrip_xy_ch[ xy_name.Hash() ] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
81  xy_name = TString::Format("strip_dg_xy%s_even",name_prefix.c_str());
82  xy_title = TString::Format("Digi XY occupancy %s at even chambers",label_prefix.c_str());
83  theStrip_xy_ch[ xy_name.Hash() ] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
84  }
85  }
86  }
87  }
88  LogDebug("GEMStripDigiValidation")<<"Booking End.\n";
89 }
90 
91 
93 }
94 
96  const edm::EventSetup& iSetup)
97 {
98  const GEMGeometry* GEMGeometry_ ;
99  try {
101  iSetup.get<MuonGeometryRecord>().get(hGeom);
102  GEMGeometry_ = &*hGeom;
103  }
105  edm::LogError("GEMStripDigiValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
106  return;
107  }
108 
110  e.getByToken( this->InputTagToken_, gem_digis);
111  if (!gem_digis.isValid()) {
112  edm::LogError("GEMStripDigiValidation") << "Cannot get strips by Token stripToken.\n";
113  return ;
114  }
115  for (GEMDigiCollection::DigiRangeIterator cItr=gem_digis->begin(); cItr!=gem_digis->end(); cItr++) {
116  GEMDetId id = (*cItr).first;
117 
118  const GeomDet* gdet = GEMGeometry_->idToDet(id);
119  if ( gdet == nullptr) {
120  std::cout<<"Getting DetId failed. Discard this gem strip hit.Maybe it comes from unmatched geometry."<<std::endl;
121  continue;
122  }
123  const BoundPlane & surface = gdet->surface();
124  const GEMEtaPartition * roll = GEMGeometry_->etaPartition(id);
125 
126  int re = id.region();
127  int la = id.layer();
128  int st = id.station();
129  Short_t chamber = (Short_t) id.chamber();
130  Short_t nroll = (Short_t) id.roll();
131 
133  for (digiItr = (*cItr ).second.first; digiItr != (*cItr ).second.second; ++digiItr)
134  {
135  Short_t strip = (Short_t) digiItr->strip();
136  Short_t bx = (Short_t) digiItr->bx();
137 
138  LocalPoint lp = roll->centreOfStrip(digiItr->strip());
139 
140  GlobalPoint gp = surface.toGlobal(lp);
141  Float_t g_r = (Float_t) gp.perp();
142  //Float_t g_eta = (Float_t) gp.eta();
143  Float_t g_phi = (Float_t) gp.phi();
144  Float_t g_x = (Float_t) gp.x();
145  Float_t g_y = (Float_t) gp.y();
146  Float_t g_z = (Float_t) gp.z();
147 
148 
149  int region_num = (re+1)/2;
150  int station_num = st-1;
151  int layer_num = la-1;
152 
153  int binX = (chamber-1)*2+layer_num;
154  int binY = nroll;
155 
156  // Fill normal plots.
157  TString histname_suffix = getSuffixName( re) ;
158  TString simple_zr_histname = TString::Format("strip_simple_zr%s",histname_suffix.Data());
159  theStrip_simple_zr[simple_zr_histname.Hash()]->Fill( fabs(g_z), g_r);
160 
161 
162  histname_suffix = getSuffixName( re, st) ;
163  TString dcEta_histname = TString::Format("strip_dcEta%s",histname_suffix.Data());
164  theStrip_dcEta[dcEta_histname.Hash()]->Fill( binX, binY);
165 
166  // Fill detail plots.
167  if ( detailPlot_) {
168  if ( theStrip_xy[region_num][station_num][layer_num] != nullptr) {
169  theStrip_xy[region_num][station_num][layer_num]->Fill(g_x,g_y);
170  theStrip_phistrip[region_num][station_num][layer_num]->Fill(g_phi,strip);
171  theStrip[region_num][station_num][layer_num]->Fill(strip);
172  theStrip_bx[region_num][station_num][layer_num]->Fill(bx);
173  theStrip_zr[region_num][station_num][layer_num]->Fill(g_z,g_r);
174 
175  std::string name_prefix = getSuffixName( re, st, la) ;
176  TString hname;
177  if ( chamber %2 == 0 ) { hname = TString::Format("strip_dg_xy%s_even",name_prefix.c_str()); }
178  else { hname = TString::Format("strip_dg_xy%s_odd",name_prefix.c_str()); }
179  theStrip_xy_ch[hname.Hash()]->Fill(g_x,g_y);
180  }
181  else {
182  std::cout<<"Error is occued when histograms is called."<<std::endl;
183  }
184  }
185  }
186  }
187 }
#define LogDebug(id)
const double Pi
T getParameter(std::string const &) const
T perp() const
Definition: PV3DBase.h:72
std::unordered_map< UInt_t, MonitorElement * > theStrip_xy_ch
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * BookHistZR(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int station_num, unsigned int layer_num=99)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
MonitorElement * theStrip_bx[2][3][2]
T y() const
Definition: PV3DBase.h:63
MonitorElement * getSimpleZR(DQMStore::IBooker &, TString, TString)
MonitorElement * BookHistXY(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int station_num, unsigned int layer_num=99)
void analyze(const edm::Event &e, const edm::EventSetup &) override
std::unordered_map< UInt_t, MonitorElement * > theStrip_dcEta
GEMStripDigiValidation(const edm::ParameterSet &)
MonitorElement * theStrip_phistrip[2][3][2]
std::string getSuffixTitle(int region, int station, int layer)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:99
const GEMGeometry * initGeometry(const edm::EventSetup &)
MonitorElement * theStrip[2][3][2]
LocalPoint centreOfStrip(int strip) const
return((rh^lh)&mask)
void Fill(long long x)
std::string getSuffixName(int region, int station, int layer)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
const std::vector< const GEMRegion * > & regions() const
Return a vector of all GEM regions.
Definition: GEMGeometry.cc:43
T z() const
Definition: PV3DBase.h:64
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
std::unordered_map< UInt_t, MonitorElement * > theStrip_simple_zr
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
std::vector< GEMDigi >::const_iterator const_iterator
MonitorElement * getDCEta(DQMStore::IBooker &, const GEMStation *, TString, TString)
MonitorElement * theStrip_zr[2][3][2]
T get() const
Definition: EventSetup.h:68
T x() const
Definition: PV3DBase.h:62
MonitorElement * theStrip_xy[2][3][2]
Definition: Run.h:44