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  //if ( nStationForLabel() ==3 ) setNStationForLabel(2) ;
14 
15  const double PI = TMath::Pi();
16 
17  int npadsGE11 = GEMGeometry_->regions()[0]->stations()[0]->superChambers()[0]->chambers()[0]->etaPartitions()[0]->npads();
18  int npadsGE21 = 0;
19  int nPads = 0;
20 
21  if ( nStation() > 1 ) {
22  //const std::vector<const GEMStation*>& sts = GEMGeometry_->regions()[0]->stations();
23  std::vector<const GEMStation*>::const_iterator it = GEMGeometry_->regions()[0]->stations().end();
24  --it;
25  npadsGE21 = (*it)->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  //if ( nStation()==3 && st ==2 ) continue; // skip st2 short
42  //st = (station->station()==1) ? 1 : 2; // 1 = station 1, 3 = station2l. Should be 2.
43  TString title_suffix2 = getSuffixTitle( re , st) ;
44  TString histname_suffix2 = getSuffixName( re, st) ;
45 
46  TString dcEta_title = TString::Format("Copad's occupancy for detector component %s; # of sub-detector ;#eta-partition",title_suffix2.Data());
47  TString dcEta_histname = TString::Format("copad_dcEta%s",histname_suffix2.Data());
48 
49  auto* dcEta = getDCEta(ibooker, station, dcEta_title, dcEta_histname);
50  if ( dcEta != nullptr) {
51  theCoPad_dcEta[ dcEta_histname.Hash() ] = dcEta;
52  }
53  }
54 
55  if ( detailPlot_) {
56  for( auto& region : GEMGeometry_->regions() ) {
57  int re = region->region();
58  int region_num = (re+1)/2;
59  std::string name_prefix = getSuffixName( re);
60  std::string label_prefix = getSuffixTitle(re);
61  for( auto& station : region->stations() ) {
62  int st = station->station();
63  int station_num = st-1;
64  //if ( nStation()==3 && st ==2 ) continue; // skip st2 short
65  //st = (station->station()==1) ? 1 : 2; // 1 = station 1, 3 = station2l. Should be 2.
66 
67  if ( st == 1 ) nPads = npadsGE11;
68  else nPads = npadsGE21;
69  name_prefix = getSuffixName( re, st) ;
70  label_prefix = getSuffixTitle( re, st) ;
71  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 );
72  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);
73  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);
74  theCSCCoPad_zr[region_num][station_num] = BookHistZR( ibooker, "copad_dg","CoPad Digi",region_num,station_num);
75  theCSCCoPad_xy[region_num][station_num] = BookHistXY( ibooker, "copad_dg","CoPad Digi",region_num,station_num);
76  TString xy_name = TString::Format("copad_dg_xy%s_odd",name_prefix.c_str());
77  TString xy_title = TString::Format("Digi XY occupancy %s at odd chambers",label_prefix.c_str());
78  theCSCCoPad_xy_ch[ xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
79  xy_name = TString::Format("copad_dg_xy%s_even",name_prefix.c_str());
80  xy_title = TString::Format("Digi XY occupancy %s at even chambers",label_prefix.c_str());
81  theCSCCoPad_xy_ch[ xy_name.Hash()] = ibooker.book2D(xy_name, xy_title, 360, -360,360, 360, -360, 360);
82  }
83  }
84  }
85  }
86 }
87 
88 
90 
91 
92 }
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("GEMCoPadDigiValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
106  return;
107  }
109  e.getByToken(InputTagToken_, gem_digis);
110  if (!gem_digis.isValid()) {
111  edm::LogError("GEMCoPadDigiValidation") << "Cannot get pads by token.";
112  return ;
113  }
114 
115 
116  // Alert! copad's station2 means GEMGeometry's station3.
117  for (GEMCoPadDigiCollection::DigiRangeIterator cItr=gem_digis->begin(); cItr!=gem_digis->end(); cItr++) {
118  GEMDetId id = (*cItr).first;
119  int re = id.region();
120  int st = id.station();
121  int la = id.layer();
122  Short_t chamber = (Short_t) id.chamber();
124  //loop over digis of given roll
125  for (digiItr = (*cItr ).second.first; digiItr != (*cItr ).second.second; ++digiItr)
126  {
127  if ( st ==2 ) st = 3; // due to gap GEMGeometry and Copad's keep information.
128 
129  GEMDetId roId = GEMDetId(re, id.ring(), st, la, chamber, digiItr->roll());
130  Short_t nroll = roId.roll();
131  LogDebug("GEMCoPadDigiValidation")<<"roId : "<<roId;
132  const GeomDet* gdet = GEMGeometry_->idToDet(roId);
133  if ( gdet == nullptr) {
134  edm::LogError("GEMCoPadDigiValidation")<<roId<<" : This part can not load from GEMGeometry // Original"<<id<<" station : "<<st;
135  edm::LogError("GEMCoPadDigiValidation")<<"Getting DetId failed. Discard this gem copad hit.Maybe it comes from unmatched geometry between GEN and DIGI.";
136  continue;
137  }
138  const BoundPlane & surface = gdet->surface();
139  const GEMEtaPartition * roll = GEMGeometry_->etaPartition(roId);
140  LogDebug("GEMCoPadDigiValidation")<<" roll's n pad : "<<roll->npads();
141 
142  Short_t pad1 = (Short_t) digiItr->pad(1);
143  Short_t pad2 = (Short_t) digiItr->pad(2);
144  Short_t bx1 = (Short_t) digiItr->bx(1);
145  Short_t bx2 = (Short_t) digiItr->bx(2);
146  LogDebug("GEMCoPadDigiValidation")<<" copad #1 pad : "<<pad1<<" bx : "<<bx1;
147  LogDebug("GEMCoPadDigiValidation")<<" copad #2 pad : "<<pad2<<" bx : "<<bx2;
148 
149  // Filtered using BX
150  if ( bx1 < (Short_t)minBXGEM_ || bx1 > (Short_t)maxBXGEM_) continue;
151  if ( bx2 < (Short_t)minBXGEM_ || bx2 > (Short_t)maxBXGEM_) continue;
152 
153  LocalPoint lp1 = roll->centreOfPad(pad1);
154  LocalPoint lp2 = roll->centreOfPad(pad2);
155 
156  GlobalPoint gp1 = surface.toGlobal(lp1);
157  GlobalPoint gp2 = surface.toGlobal(lp2);
158  Float_t g_r1 = (Float_t) gp1.perp();
159  Float_t g_r2 = (Float_t) gp2.perp();
160  Float_t g_z1 = (Float_t) gp1.z();
161  Float_t g_z2 = (Float_t) gp2.z();
162 
163  Float_t g_phi = (Float_t) gp1.phi();
164  Float_t g_x = (Float_t) gp1.x();
165  Float_t g_y = (Float_t) gp1.y();
166 
167  int region_num=0;
168  if ( re == -1 ) region_num = 0 ;
169  else if (re == 1 ) region_num = 1;
170  else {
171  edm::LogError("GEMCoPadDIGIValidation")<<"region : "<<re<<std::endl;
172  }
173  int binX = (chamber-1)*2+(la-1);
174  int binY = nroll;
175  int station_num = st-1;
176 
177  // Fill normal plots.
178  TString histname_suffix = getSuffixName( re);
179  TString simple_zr_histname = TString::Format("copad_simple_zr%s",histname_suffix.Data());
180  theCoPad_simple_zr[simple_zr_histname.Hash()]->Fill( fabs(g_z1), g_r1);
181  theCoPad_simple_zr[simple_zr_histname.Hash()]->Fill( fabs(g_z2), g_r2);
182 
183  histname_suffix = getSuffixName( re, st ) ;
184  TString dcEta_histname = TString::Format("copad_dcEta%s",histname_suffix.Data());
185  theCoPad_dcEta[dcEta_histname.Hash()]->Fill( binX, binY);
186  theCoPad_dcEta[dcEta_histname.Hash()]->Fill( binX+1, binY);
187 
188  // Fill detail plots.
189  if ( detailPlot_) {
190  theCSCCoPad_xy[region_num][station_num]->Fill(g_x,g_y);
191  theCSCCoPad_phipad[region_num][station_num]->Fill(g_phi,pad1);
192  theCSCCoPad[region_num][station_num]->Fill(pad1);
193  theCSCCoPad_bx[region_num][station_num]->Fill(bx1);
194  theCSCCoPad_bx[region_num][station_num]->Fill(bx2);
195  theCSCCoPad_zr[region_num][station_num]->Fill(g_z1,g_r1);
196  theCSCCoPad_zr[region_num][station_num]->Fill(g_z2,g_r2);
197  std::string name_prefix = getSuffixName( re, st) ;
198  TString hname;
199  if ( chamber %2 == 0 ) { hname = TString::Format("copad_dg_xy%s_even",name_prefix.c_str()); }
200  else { hname = TString::Format("copad_dg_xy%s_odd",name_prefix.c_str()); }
201  theCSCCoPad_xy_ch[hname.Hash()]->Fill(g_x,g_y);
202  }
203  }
204  }
205 }
#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
#define PI
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:40
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:103
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
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:43