CMS 3D CMS Logo

GEMPadDigiValidation.cc
Go to the documentation of this file.
2 #include <TMath.h>
3 
5 {
6  InputTagToken_ = consumes<GEMPadDigiCollection>(cfg.getParameter<edm::InputTag>("PadLabel"));
7  detailPlot_ = cfg.getParameter<bool>("detailPlot");
8 }
10 
11  const GEMGeometry* GEMGeometry_ = initGeometry(iSetup);
12  if ( GEMGeometry_ == nullptr) return ;
13  LogDebug("GEMPadDigiValidation")<<"Geometry is acquired from MuonGeometryRecord\n";
14  ibooker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask");
15  LogDebug("GEMPadDigiValidation")<<"ibooker set current folder\n";
16 
17  if ( GEMGeometry_ == nullptr) return ;
18  int npadsGE11 = GEMGeometry_->regions()[0]->stations()[0]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
19  int npadsGE21 = 0;
20  int nPads = 0;
21 
22  if ( nStation() > 1 ) {
23  npadsGE21 = GEMGeometry_->regions()[0]->stations()[1]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
24  }
25 
26 
27  for( auto& region : GEMGeometry_->regions() ){
28  int re = region->region();
29  TString title_suffix = getSuffixTitle(re) ;
30  TString histname_suffix = getSuffixName( re ) ;
31  TString simpleZR_title = TString::Format("ZR Occupancy%s; |Z|(cm) ; R(cm)",title_suffix.Data());
32  TString simpleZR_histname = TString::Format("pad_simple_zr%s",histname_suffix.Data());
33 
34  auto* simpleZR = getSimpleZR(ibooker, simpleZR_title, simpleZR_histname);
35  if ( simpleZR != nullptr) {
36  thePad_simple_zr[simpleZR_histname.Hash() ] = simpleZR;
37  }
38  for( auto& station : region->stations()) {
39  int st = station->station();
40  TString title_suffix2 = getSuffixTitle( re, st) ;
41  TString histname_suffix2 = getSuffixName( re, st) ;
42 
43  TString dcEta_title = TString::Format("Occupancy for detector component %s;;#eta-partition",title_suffix2.Data());
44  TString dcEta_histname = TString::Format("pad_dcEta%s",histname_suffix2.Data());
45 
46  auto* dcEta = getDCEta(ibooker, station, dcEta_title, dcEta_histname);
47  if ( dcEta != nullptr) {
48  thePad_dcEta[ dcEta_histname.Hash() ] = dcEta;
49  }
50  }
51  }
52 
53 
54  if ( detailPlot_ ) {
55  for( auto& region : GEMGeometry_->regions() ) {
56  int re = region->region();
57  int region_num = (re+1)/2;
58  for( auto& station : region->stations() ) {
59  int st = station->station();
60  int station_num = st-1;
61  if ( station_num == 0 ) nPads = npadsGE11;
62  else nPads = npadsGE21;
63  for( int la = 1 ; la <= 2 ; la++) {
64  int layer_num = la-1;
65  std::string name_prefix = getSuffixName( re, st, la);
66  std::string label_prefix = getSuffixTitle( re, st, la) ;
67  theCSCPad_phipad[region_num][station_num][layer_num] = ibooker.book2D( ("pad_dg_phipad"+name_prefix).c_str(), ("Digi occupancy: "+label_prefix+"; phi [rad]; Pad number").c_str(), 280,-TMath::Pi(),TMath::Pi(), nPads/2,0,nPads );
68  theCSCPad[region_num][station_num][layer_num] = ibooker.book1D( ("pad_dg"+name_prefix).c_str(), ("Digi occupancy per pad number: "+label_prefix+";Pad number; entries").c_str(), nPads,0.5,nPads+0.5);
69  theCSCPad_bx[region_num][station_num][layer_num] = ibooker.book1D( ("pad_dg_bx"+name_prefix).c_str(), ("Bunch crossing: "+label_prefix+"; bunch crossing ; entries").c_str(), 11,-5.5,5.5);
70  theCSCPad_zr[region_num][station_num][layer_num] = BookHistZR(ibooker,"pad_dg","Pad Digi",region_num,station_num,layer_num);
71  theCSCPad_xy[region_num][station_num][layer_num] = BookHistXY(ibooker,"pad_dg","Pad Digi",region_num,station_num,layer_num);
72  TString xy_name = TString::Format("pad_dg_xy%s_odd",name_prefix.c_str());
73  TString xy_title = TString::Format("Digi XY occupancy %s at odd chambers",label_prefix.c_str());
74  theCSCPad_xy_ch[ xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
75  xy_name = TString::Format("pad_dg_xy%s_even",name_prefix.c_str());
76  xy_title = TString::Format("Digi XY occupancy %s at even chambers",label_prefix.c_str());
77  theCSCPad_xy_ch[ xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
78  }
79  }
80  }
81  }
82 }
83 
84 
86 
87 
88 }
89 
90 
92  const edm::EventSetup& iSetup)
93 {
94  const GEMGeometry* GEMGeometry_ ;
95  try {
97  iSetup.get<MuonGeometryRecord>().get(hGeom);
98  GEMGeometry_ = &*hGeom;
99  }
101  edm::LogError("GEMPadDigiValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
102  return;
103  }
105  e.getByToken(InputTagToken_, gem_digis);
106  if (!gem_digis.isValid()) {
107  edm::LogError("GEMPadDigiValidation") << "Cannot get pads by label GEMPadToken.";
108  }
109 
110  for (GEMPadDigiCollection::DigiRangeIterator cItr=gem_digis->begin(); cItr!=gem_digis->end(); cItr++) {
111 
112  GEMDetId id = (*cItr).first;
113 
114  const GeomDet* gdet = GEMGeometry_->idToDet(id);
115  if ( gdet == nullptr) {
116  std::cout<<"Getting DetId failed. Discard this gem pad hit.Maybe it comes from unmatched geometry."<<std::endl;
117  continue;
118  }
119  const BoundPlane & surface = gdet->surface();
120  const GEMEtaPartition * roll = GEMGeometry_->etaPartition(id);
121 
122  int re = id.region();
123  int la = id.layer();
124  int st = id.station();
125  Short_t chamber = (Short_t) id.chamber();
126  Short_t nroll = (Short_t) id.roll();
128 
129  //loop over digis of given roll
130  //
131  for (digiItr = (*cItr ).second.first; digiItr != (*cItr ).second.second; ++digiItr)
132  {
133  Short_t pad = (Short_t) digiItr->pad();
134  Short_t bx = (Short_t) digiItr->bx();
135 
136  LocalPoint lp = roll->centreOfPad(digiItr->pad());
137 
138  GlobalPoint gp = surface.toGlobal(lp);
139  Float_t g_r = (Float_t) gp.perp();
140  Float_t g_phi = (Float_t) gp.phi();
141  Float_t g_x = (Float_t) gp.x();
142  Float_t g_y = (Float_t) gp.y();
143  Float_t g_z = (Float_t) gp.z();
144  edm::LogInfo("GEMPadDIGIValidation")<<"Global x "<<g_x<<"Global y "<<g_y<<"\n";
145  edm::LogInfo("GEMPadDIGIValidation")<<"Global pad "<<pad<<"Global phi "<<g_phi<<std::endl;
146  edm::LogInfo("GEMPadDIGIValidation")<<"Global bx "<<bx<<std::endl;
147 
148  int region_num = (re+1)/2;
149  int station_num = st-1;
150  int layer_num = la-1;
151  int binX = (chamber-1)*2+layer_num;
152  int binY = nroll;
153 
154  // Fill normal plots.
155  TString histname_suffix = getSuffixName( re);
156  TString simple_zr_histname = TString::Format("pad_simple_zr%s",histname_suffix.Data());
157  thePad_simple_zr[simple_zr_histname.Hash()]->Fill( fabs(g_z), g_r);
158 
159  histname_suffix = getSuffixName( re, st);
160  TString dcEta_histname = TString::Format("pad_dcEta%s",histname_suffix.Data());
161  thePad_dcEta[dcEta_histname.Hash()]->Fill( binX, binY);
162 
163  if ( detailPlot_) {
164  theCSCPad_xy[region_num][station_num][layer_num]->Fill(g_x,g_y);
165  theCSCPad_phipad[region_num][station_num][layer_num]->Fill(g_phi,pad);
166  theCSCPad[region_num][station_num][layer_num]->Fill(pad);
167  theCSCPad_bx[region_num][station_num][layer_num]->Fill(bx);
168  theCSCPad_zr[region_num][station_num][layer_num]->Fill(g_z,g_r);
169  std::string name_prefix = getSuffixName( re, st, la);
170  TString hname;
171  if ( chamber %2 == 0 ) { hname = TString::Format("pad_dg_xy%s_even",name_prefix.c_str()); }
172  else { hname = TString::Format("pad_dg_xy%s_odd",name_prefix.c_str()); }
173  theCSCPad_xy_ch[hname.Hash()]->Fill(g_x,g_y);
174  }
175  }
176  }
177 }
#define LogDebug(id)
MonitorElement * theCSCPad_zr[2][3][2]
const double Pi
T getParameter(std::string const &) const
unsigned int nStation()
T perp() const
Definition: PV3DBase.h:72
MonitorElement * theCSCPad[2][3][2]
MonitorElement * theCSCPad_xy[2][3][2]
MonitorElement * BookHistZR(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int station_num, unsigned int layer_num=99)
std::unordered_map< UInt_t, MonitorElement * > thePad_dcEta
std::unordered_map< UInt_t, MonitorElement * > theCSCPad_xy_ch
edm::EDGetToken InputTagToken_
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
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)
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 &)
void Fill(long long x)
std::string getSuffixName(int region, int station, int layer)
GEMPadDigiValidation(const edm::ParameterSet &)
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
float pad(const LocalPoint &lp) const
returns FRACTIONAL pad number [0.,npads] for a point
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * theCSCPad_bx[2][3][2]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
virtual const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
const T & get() const
Definition: EventSetup.h:56
std::vector< GEMPadDigi >::const_iterator const_iterator
MonitorElement * getDCEta(DQMStore::IBooker &, const GEMStation *, TString, TString)
return(e1-e2)*(e1-e2)+dp *dp
LocalPoint centreOfPad(int pad) const
std::unordered_map< UInt_t, MonitorElement * > thePad_simple_zr
void analyze(const edm::Event &e, const edm::EventSetup &) override
MonitorElement * theCSCPad_phipad[2][3][2]
T x() const
Definition: PV3DBase.h:62
Definition: Run.h:42