CMS 3D CMS Logo

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