CMS 3D CMS Logo

GEMCoPadDigiValidation.cc
Go to the documentation of this file.
2 #include <TMath.h>
3 
5 {
6  InputTagToken_ = consumes<GEMCoPadDigiCollection>(cfg.getParameter<edm::InputTag>("CopadLabel"));
7  detailPlot_ = cfg.getParameter<bool>("detailPlot");
8  minBXGEM_ = cfg.getParameter<int>("minBXGEM");
9  maxBXGEM_ = cfg.getParameter<int>("maxBXGEM");
10 }
12  const GEMGeometry* GEMGeometry_ = initGeometry(iSetup);
13  if ( GEMGeometry_ == nullptr) return ;
14  LogDebug("GEMCoPadDigiValidation")<<"Geometry is acquired from MuonGeometryRecord\n";
15  ibooker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask");
16  LogDebug("GEMCoPadDigiValidation")<<"ibooker set current folder\n";
17 
18  const double PI = TMath::Pi();
19 
20  int npadsGE11 = GEMGeometry_->regions()[0]->stations()[0]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
21  int npadsGE21 = 0;
22  int nPads = 0;
23 
24  if ( GEMGeometry_->regions()[0]->stations()[1]->superChambers().size() != 0 ) {
25  npadsGE21 = GEMGeometry_->regions()[0]->stations()[1]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
26  }
27 
28  for( auto& region : GEMGeometry_->regions() ){
29  int re = region->region();
30  TString title_suffix = getSuffixTitle(re);
31  TString histname_suffix = getSuffixName( re) ;
32  TString simpleZR_title = TString::Format("Copad ZR Occupancy%s; |Z|(cm) ; R(cm)",title_suffix.Data());
33  TString simpleZR_histname = TString::Format("copad_simple_zr%s",histname_suffix.Data());
34 
35  auto* simpleZR = getSimpleZR(ibooker, simpleZR_title, simpleZR_histname);
36  if ( simpleZR != nullptr) {
37  theCoPad_simple_zr[simpleZR_histname.Hash() ] = simpleZR;
38  }
39  for( auto& station : region->stations()) {
40  int st = station->station();
41  TString title_suffix2 = getSuffixTitle( re , st) ;
42  TString histname_suffix2 = getSuffixName( re, st) ;
43 
44  TString dcEta_title = TString::Format("Copad's occupancy for detector component %s; # of sub-detector ;#eta-partition",title_suffix2.Data());
45  TString dcEta_histname = TString::Format("copad_dcEta%s",histname_suffix2.Data());
46 
47  auto* dcEta = getDCEta(ibooker, station, dcEta_title, dcEta_histname);
48  if ( dcEta != nullptr) {
49  theCoPad_dcEta[ dcEta_histname.Hash() ] = dcEta;
50  }
51  }
52 
53  if ( detailPlot_) {
54  for( auto& region : GEMGeometry_->regions() ) {
55  int re = region->region();
56  int region_num = (re+1)/2;
57  std::string name_prefix = getSuffixName( re);
58  std::string label_prefix = getSuffixTitle(re);
59  for( auto& station : region->stations() ) {
60  int st = station->station();
61  int station_num = st-1;
62 
63  if ( st == 1 ) nPads = npadsGE11;
64  else nPads = npadsGE21;
65  name_prefix = getSuffixName( re, st) ;
66  label_prefix = getSuffixTitle( re, st) ;
67  theCSCCoPad_phipad[region_num][station_num] = ibooker.book2D( ("copad_dg_phipad"+name_prefix).c_str(), ("Digi occupancy: "+label_prefix+"; phi [rad]; Pad number").c_str(), 280,-PI,PI, nPads/2,0,nPads );
68  theCSCCoPad[region_num][station_num] = ibooker.book1D( ("copad_dg"+name_prefix).c_str(), ("Digi occupancy per pad number: "+label_prefix+";Pad number; entries").c_str(), nPads,0.5,nPads+0.5);
69  theCSCCoPad_bx[region_num][station_num] = ibooker.book1D( ("copad_dg_bx"+name_prefix).c_str(), ("Bunch crossing: "+label_prefix+"; bunch crossing ; entries").c_str(), 11,-5.5,5.5);
70  theCSCCoPad_zr[region_num][station_num] = BookHistZR( ibooker, "copad_dg","CoPad Digi",region_num,station_num);
71  theCSCCoPad_xy[region_num][station_num] = BookHistXY( ibooker, "copad_dg","CoPad Digi",region_num,station_num);
72  TString xy_name = TString::Format("copad_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  theCSCCoPad_xy_ch[ xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
75  xy_name = TString::Format("copad_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  theCSCCoPad_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("GEMCoPadDigiValidation") << "+++ 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("GEMCoPadDigiValidation") << "Cannot get pads by token.";
108  return ;
109  }
110 
111  for (GEMCoPadDigiCollection::DigiRangeIterator cItr=gem_digis->begin(); cItr!=gem_digis->end(); cItr++) {
112  GEMDetId id = (*cItr).first;
113  int re = id.region();
114  int st = id.station();
115  int la = id.layer();
116  Short_t chamber = (Short_t) id.chamber();
118  //loop over digis of given roll
119  for (digiItr = (*cItr ).second.first; digiItr != (*cItr ).second.second; ++digiItr)
120  {
121  // GEM copads are stored per super chamber!
122  GEMDetId schId = GEMDetId(re, id.ring(), st, 0, chamber, 0);
123  Short_t nroll = (*digiItr).roll();
124  LogDebug("GEMCoPadDigiValidation")<<"schId : "<<schId;
125  const GeomDet* gdet = GEMGeometry_->idToDet(schId);
126  if ( gdet == nullptr) {
127  edm::LogError("GEMCoPadDigiValidation")<<schId<<" : This detId cannot be loaded from GEMGeometry // Original"<<id<<" station : "<<st;
128  edm::LogError("GEMCoPadDigiValidation")<<"Getting DetId failed. Discard this gem copad hit. ";
129  continue;
130  }
131  const BoundPlane & surface = gdet->surface();
132  const GEMSuperChamber * superChamber = GEMGeometry_->superChamber(schId);
133  LogDebug("GEMCoPadDigiValidation")<<" #pads in this partition : "<< superChamber->chamber(1)->etaPartition(1)->npads();
134 
135  Short_t pad1 = (Short_t) digiItr->pad(1);
136  Short_t pad2 = (Short_t) digiItr->pad(2);
137  Short_t bx1 = (Short_t) digiItr->bx(1);
138  Short_t bx2 = (Short_t) digiItr->bx(2);
139  LogDebug("GEMCoPadDigiValidation")<<" copad #1 pad : "<<pad1<<" bx : "<<bx1;
140  LogDebug("GEMCoPadDigiValidation")<<" copad #2 pad : "<<pad2<<" bx : "<<bx2;
141 
142  // Filtered using BX
143  if ( bx1 < (Short_t)minBXGEM_ || bx1 > (Short_t)maxBXGEM_) continue;
144  if ( bx2 < (Short_t)minBXGEM_ || bx2 > (Short_t)maxBXGEM_) continue;
145 
146  LocalPoint lp1 = superChamber->chamber(1)->etaPartition(nroll)->centreOfPad(pad1);
147  LocalPoint lp2 = superChamber->chamber(2)->etaPartition(nroll)->centreOfPad(pad2);
148 
149  GlobalPoint gp1 = surface.toGlobal(lp1);
150  GlobalPoint gp2 = surface.toGlobal(lp2);
151  Float_t g_r1 = (Float_t) gp1.perp();
152  Float_t g_r2 = (Float_t) gp2.perp();
153  Float_t g_z1 = (Float_t) gp1.z();
154  Float_t g_z2 = (Float_t) gp2.z();
155 
156  Float_t g_phi = (Float_t) gp1.phi();
157  Float_t g_x = (Float_t) gp1.x();
158  Float_t g_y = (Float_t) gp1.y();
159 
160  int region_num=0;
161  if ( re == -1 ) region_num = 0 ;
162  else if (re == 1 ) region_num = 1;
163  else {
164  edm::LogError("GEMCoPadDigiValidation")<<"region : "<<re<<std::endl;
165  }
166  int binX = (chamber-1)*2+la;
167  int binY = nroll;
168  int station_num = st-1;
169 
170  // Fill normal plots.
171  TString histname_suffix = getSuffixName( re);
172  TString simple_zr_histname = TString::Format("copad_simple_zr%s",histname_suffix.Data());
173  theCoPad_simple_zr[simple_zr_histname.Hash()]->Fill( fabs(g_z1), g_r1);
174  theCoPad_simple_zr[simple_zr_histname.Hash()]->Fill( fabs(g_z2), g_r2);
175 
176  histname_suffix = getSuffixName( re, st ) ;
177  TString dcEta_histname = TString::Format("copad_dcEta%s",histname_suffix.Data());
178  theCoPad_dcEta[dcEta_histname.Hash()]->Fill( binX, binY);
179  theCoPad_dcEta[dcEta_histname.Hash()]->Fill( binX+1, binY);
180 
181  // Fill detail plots.
182  if ( detailPlot_) {
183  theCSCCoPad_xy[region_num][station_num]->Fill(g_x,g_y);
184  theCSCCoPad_phipad[region_num][station_num]->Fill(g_phi,pad1);
185  theCSCCoPad[region_num][station_num]->Fill(pad1);
186  theCSCCoPad_bx[region_num][station_num]->Fill(bx1);
187  theCSCCoPad_bx[region_num][station_num]->Fill(bx2);
188  theCSCCoPad_zr[region_num][station_num]->Fill(g_z1,g_r1);
189  theCSCCoPad_zr[region_num][station_num]->Fill(g_z2,g_r2);
190  std::string name_prefix = getSuffixName( re, st) ;
191  TString hname;
192  if ( chamber %2 == 0 ) { hname = TString::Format("copad_dg_xy%s_even",name_prefix.c_str()); }
193  else { hname = TString::Format("copad_dg_xy%s_odd",name_prefix.c_str()); }
194  theCSCCoPad_xy_ch[hname.Hash()]->Fill(g_x,g_y);
195  }
196  }
197  }
198 }
#define LogDebug(id)
const double Pi
T getParameter(std::string const &) const
const GEMChamber * chamber(GEMDetId id) const
Return the chamber corresponding to the given id.
MonitorElement * theCSCCoPad_zr[2][3]
T perp() const
Definition: PV3DBase.h:72
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
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::unordered_map< UInt_t, MonitorElement * > theCSCCoPad_xy_ch
std::string getSuffixTitle(int region, int station, int layer)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const GEMGeometry * initGeometry(const edm::EventSetup &)
void Fill(long long x)
std::string getSuffixName(int region, int station, int layer)
GEMCoPadDigiValidation(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
std::unordered_map< UInt_t, MonitorElement * > theCoPad_dcEta
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int npads() const
number of GEM-CSC trigger readout pads in partition
bool isValid() const
Definition: HandleBase.h:74
#define PI
Definition: QcdUeDQM.h:36
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: GEMDetId.h:53
const GEMSuperChamber * superChamber(GEMDetId id) const
Definition: GEMGeometry.cc:91
MonitorElement * theCSCCoPad_xy[2][3]
MonitorElement * theCSCCoPad[2][3]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
MonitorElement * theCSCCoPad_phipad[2][3]
MonitorElement * theCSCCoPad_bx[2][3]
const T & get() const
Definition: EventSetup.h:55
std::vector< GEMCoPadDigi >::const_iterator const_iterator
MonitorElement * getDCEta(DQMStore::IBooker &, const GEMStation *, TString, TString)
return(e1-e2)*(e1-e2)+dp *dp
void analyze(const edm::Event &e, const edm::EventSetup &) override
LocalPoint centreOfPad(int pad) const
std::unordered_map< UInt_t, MonitorElement * > theCoPad_simple_zr
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return the eta partition corresponding to the given id.
Definition: GEMChamber.cc:47
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
T x() const
Definition: PV3DBase.h:62
Definition: Run.h:43