CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
14  const double PI = TMath::Pi();
15 
16  int npadsGE11 = GEMGeometry_->regions()[0]->stations()[0]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
17  int npadsGE21 = 0;
18  int nPads = 0;
19 
20  if ( nStation() > 1 ) {
21  npadsGE21 = GEMGeometry_->regions()[0]->stations()[1]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
22  }
23 
24  for( auto& region : GEMGeometry_->regions() ){
25  int re = region->region();
26  TString title_suffix = getSuffixTitle(re);
27  TString histname_suffix = getSuffixName( re) ;
28  TString simpleZR_title = TString::Format("Copad ZR Occupancy%s; |Z|(cm) ; R(cm)",title_suffix.Data());
29  TString simpleZR_histname = TString::Format("copad_simple_zr%s",histname_suffix.Data());
30 
31  auto* simpleZR = getSimpleZR(ibooker, simpleZR_title, simpleZR_histname);
32  if ( simpleZR != nullptr) {
33  theCoPad_simple_zr[simpleZR_histname.Hash() ] = simpleZR;
34  }
35  for( auto& station : region->stations()) {
36  int st = station->station();
37  TString title_suffix2 = getSuffixTitle( re , st) ;
38  TString histname_suffix2 = getSuffixName( re, st) ;
39 
40  TString dcEta_title = TString::Format("Copad's occupancy for detector component %s; # of sub-detector ;#eta-partition",title_suffix2.Data());
41  TString dcEta_histname = TString::Format("copad_dcEta%s",histname_suffix2.Data());
42 
43  auto* dcEta = getDCEta(ibooker, station, dcEta_title, dcEta_histname);
44  if ( dcEta != nullptr) {
45  theCoPad_dcEta[ dcEta_histname.Hash() ] = dcEta;
46  }
47  }
48 
49  if ( detailPlot_) {
50  for( auto& region : GEMGeometry_->regions() ) {
51  int re = region->region();
52  int region_num = (re+1)/2;
53  std::string name_prefix = getSuffixName( re);
54  std::string label_prefix = getSuffixTitle(re);
55  for( auto& station : region->stations() ) {
56  int st = station->station();
57  int station_num = st-1;
58 
59  if ( st == 1 ) nPads = npadsGE11;
60  else nPads = npadsGE21;
61  name_prefix = getSuffixName( re, st) ;
62  label_prefix = getSuffixTitle( re, st) ;
63  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 );
64  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);
65  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);
66  theCSCCoPad_zr[region_num][station_num] = BookHistZR( ibooker, "copad_dg","CoPad Digi",region_num,station_num);
67  theCSCCoPad_xy[region_num][station_num] = BookHistXY( ibooker, "copad_dg","CoPad Digi",region_num,station_num);
68  TString xy_name = TString::Format("copad_dg_xy%s_odd",name_prefix.c_str());
69  TString xy_title = TString::Format("Digi XY occupancy %s at odd chambers",label_prefix.c_str());
70  theCSCCoPad_xy_ch[ xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
71  xy_name = TString::Format("copad_dg_xy%s_even",name_prefix.c_str());
72  xy_title = TString::Format("Digi XY occupancy %s at even chambers",label_prefix.c_str());
73  theCSCCoPad_xy_ch[ xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
74  }
75  }
76  }
77  }
78 }
79 
80 
82 
83 
84 }
85 
86 
88  const edm::EventSetup& iSetup)
89 {
90  const GEMGeometry* GEMGeometry_;
91  try {
93  iSetup.get<MuonGeometryRecord>().get(hGeom);
94  GEMGeometry_ = &*hGeom;
95  }
97  edm::LogError("GEMCoPadDigiValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
98  return;
99  }
101  e.getByToken(InputTagToken_, gem_digis);
102  if (!gem_digis.isValid()) {
103  edm::LogError("GEMCoPadDigiValidation") << "Cannot get pads by token.";
104  return ;
105  }
106 
107  for (GEMCoPadDigiCollection::DigiRangeIterator cItr=gem_digis->begin(); cItr!=gem_digis->end(); cItr++) {
108  GEMDetId id = (*cItr).first;
109  int re = id.region();
110  int st = id.station();
111  int la = id.layer();
112  Short_t chamber = (Short_t) id.chamber();
114  //loop over digis of given roll
115  for (digiItr = (*cItr ).second.first; digiItr != (*cItr ).second.second; ++digiItr)
116  {
117  GEMDetId roId = GEMDetId(re, id.ring(), st, la, chamber, digiItr->roll());
118  Short_t nroll = roId.roll();
119  LogDebug("GEMCoPadDigiValidation")<<"roId : "<<roId;
120  const GeomDet* gdet = GEMGeometry_->idToDet(roId);
121  if ( gdet == nullptr) {
122  edm::LogError("GEMCoPadDigiValidation")<<roId<<" : This part can not load from GEMGeometry // Original"<<id<<" station : "<<st;
123  edm::LogError("GEMCoPadDigiValidation")<<"Getting DetId failed. Discard this gem copad hit.Maybe it comes from unmatched geometry between GEN and DIGI.";
124  continue;
125  }
126  const BoundPlane & surface = gdet->surface();
127  const GEMEtaPartition * roll = GEMGeometry_->etaPartition(roId);
128  LogDebug("GEMCoPadDigiValidation")<<" roll's n pad : "<<roll->npads();
129 
130  Short_t pad1 = (Short_t) digiItr->pad(1);
131  Short_t pad2 = (Short_t) digiItr->pad(2);
132  Short_t bx1 = (Short_t) digiItr->bx(1);
133  Short_t bx2 = (Short_t) digiItr->bx(2);
134  LogDebug("GEMCoPadDigiValidation")<<" copad #1 pad : "<<pad1<<" bx : "<<bx1;
135  LogDebug("GEMCoPadDigiValidation")<<" copad #2 pad : "<<pad2<<" bx : "<<bx2;
136 
137  // Filtered using BX
138  if ( bx1 < (Short_t)minBXGEM_ || bx1 > (Short_t)maxBXGEM_) continue;
139  if ( bx2 < (Short_t)minBXGEM_ || bx2 > (Short_t)maxBXGEM_) continue;
140 
141  LocalPoint lp1 = roll->centreOfPad(pad1);
142  LocalPoint lp2 = roll->centreOfPad(pad2);
143 
144  GlobalPoint gp1 = surface.toGlobal(lp1);
145  GlobalPoint gp2 = surface.toGlobal(lp2);
146  Float_t g_r1 = (Float_t) gp1.perp();
147  Float_t g_r2 = (Float_t) gp2.perp();
148  Float_t g_z1 = (Float_t) gp1.z();
149  Float_t g_z2 = (Float_t) gp2.z();
150 
151  Float_t g_phi = (Float_t) gp1.phi();
152  Float_t g_x = (Float_t) gp1.x();
153  Float_t g_y = (Float_t) gp1.y();
154 
155  int region_num=0;
156  if ( re == -1 ) region_num = 0 ;
157  else if (re == 1 ) region_num = 1;
158  else {
159  edm::LogError("GEMCoPadDIGIValidation")<<"region : "<<re<<std::endl;
160  }
161  int binX = (chamber-1)*2+(la-1);
162  int binY = nroll;
163  int station_num = st-1;
164 
165  // Fill normal plots.
166  TString histname_suffix = getSuffixName( re);
167  TString simple_zr_histname = TString::Format("copad_simple_zr%s",histname_suffix.Data());
168  theCoPad_simple_zr[simple_zr_histname.Hash()]->Fill( fabs(g_z1), g_r1);
169  theCoPad_simple_zr[simple_zr_histname.Hash()]->Fill( fabs(g_z2), g_r2);
170 
171  histname_suffix = getSuffixName( re, st ) ;
172  TString dcEta_histname = TString::Format("copad_dcEta%s",histname_suffix.Data());
173  theCoPad_dcEta[dcEta_histname.Hash()]->Fill( binX, binY);
174  theCoPad_dcEta[dcEta_histname.Hash()]->Fill( binX+1, binY);
175 
176  // Fill detail plots.
177  if ( detailPlot_) {
178  theCSCCoPad_xy[region_num][station_num]->Fill(g_x,g_y);
179  theCSCCoPad_phipad[region_num][station_num]->Fill(g_phi,pad1);
180  theCSCCoPad[region_num][station_num]->Fill(pad1);
181  theCSCCoPad_bx[region_num][station_num]->Fill(bx1);
182  theCSCCoPad_bx[region_num][station_num]->Fill(bx2);
183  theCSCCoPad_zr[region_num][station_num]->Fill(g_z1,g_r1);
184  theCSCCoPad_zr[region_num][station_num]->Fill(g_z2,g_r2);
185  std::string name_prefix = getSuffixName( re, st) ;
186  TString hname;
187  if ( chamber %2 == 0 ) { hname = TString::Format("copad_dg_xy%s_even",name_prefix.c_str()); }
188  else { hname = TString::Format("copad_dg_xy%s_odd",name_prefix.c_str()); }
189  theCSCCoPad_xy_ch[hname.Hash()]->Fill(g_x,g_y);
190  }
191  }
192  }
193 }
#define LogDebug(id)
const double Pi
T getParameter(std::string const &) const
unsigned int nStation()
tuple cfg
Definition: looper.py:293
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)
virtual const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
int roll() const
Definition: GEMDetId.h:80
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 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)
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:75
#define PI
Definition: QcdUeDQM.h:36
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: GEMDetId.h:53
MonitorElement * theCSCCoPad_xy[2][3]
MonitorElement * theCSCCoPad[2][3]
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * theCSCCoPad_phipad[2][3]
MonitorElement * theCSCCoPad_bx[2][3]
const T & get() const
Definition: EventSetup.h:56
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
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
T x() const
Definition: PV3DBase.h:62
Definition: Run.h:42