CMS 3D CMS Logo

GEMBaseValidation.cc
Go to the documentation of this file.
4 //#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
6 #include <memory>
7 using namespace std;
9 {
10  nBinZR_ = ps.getUntrackedParameter< std::vector<double> >("nBinGlobalZR") ;
11  RangeZR_ = ps.getUntrackedParameter< std::vector<double> >("RangeGlobalZR");
12  nBinXY_ = ps.getUntrackedParameter< int >("nBinGlobalXY",360) ;
13 
14  regionLabel.push_back("-1");
15  regionLabel.push_back("1" );
16 
17 
18  layerLabel.push_back("1");
19  layerLabel.push_back("2");
20 }
21 
23  const GEMGeometry* GEMGeometry_ = nullptr;
24  try {
26  iSetup.get<MuonGeometryRecord>().get(hGeom);
27  GEMGeometry_ = &*hGeom;
28  }
30  edm::LogError("MuonGEMBaseValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
31  return nullptr;
32  }
33 
34  LogDebug("MuonBaseValidation") << "GEMGeometry_->regions().size() " << GEMGeometry_->regions().size() << "\n";
35  LogDebug("MuonBaseValidation") << "GEMGeometry_->stations().size() " << GEMGeometry_->regions().front()->stations().size() << "\n";
36  LogDebug("MuonBaseValidation") << "GEMGeometry_->superChambers().size() " << GEMGeometry_->superChambers().size() << "\n";
37  LogDebug("MuonBaseValidation") << "GEMGeometry_->chambers().size() " << GEMGeometry_->chambers().size() << "\n";
38  LogDebug("MuonBaseValidation") << "GEMGeometry_->etaPartitions().size() " << GEMGeometry_->etaPartitions().size() << "\n";
39 
40  nregion = GEMGeometry_->regions().size();
41  nstation = GEMGeometry_->regions().front()->stations().size() ;
42  nstationForLabel = nstation;
43  npart = GEMGeometry_->chambers().front()->etaPartitions().size();
44 
45  return GEMGeometry_;
46 }
47 
48 string GEMBaseValidation::getSuffixName(int region, int station, int layer){
49  if ( region == -1 ) region =0 ;
50  else if ( region >1 ) std::cout<<"Name)Alert! Region must be -1 or 1 : "<<region<<" "<<station<<" "<<layer<<std::endl;
51  return string("_r")+regionLabel[region]+"_st"+getStationLabel(station)+"_l"+layerLabel[layer-1];
52 }
53 string GEMBaseValidation::getSuffixName(int region, int station){
54  if ( region == -1 ) region =0 ;
55  else if ( region >1 ) std::cout<<"Name)Alert! Region must be -1 or 1 : "<<region<<" "<<station<<std::endl;
56  return string("_r")+regionLabel[region]+"_st"+getStationLabel(station);
57 }
59  if ( region == -1 ) region =0 ;
60  else if ( region >1 ) std::cout<<"Name)Alert! Region must be -1 or 1 : "<<region<<std::endl;
61  return string("_r")+regionLabel[region];
62 }
63 
64 string GEMBaseValidation::getSuffixTitle(int region, int station, int layer){
65  if ( region == -1 ) region =0 ;
66  else if ( region >1 ) std::cout<<"Title)Alert! Region must be -1 or 1 : "<<region<<" "<<station<<" "<<layer<<std::endl;
67  return string("Region ")+regionLabel[region]+" Station "+getStationLabel(station)+" Layer "+layerLabel[layer-1];
68 }
70  if ( region == -1 ) region =0 ;
71  else if ( region >1 ) std::cout<<"Title)Alert! Region must be -1 or 1 : "<<region<<" "<<station<<std::endl;
72  return string("Region ")+regionLabel[region]+" Station "+getStationLabel(station);
73 }
75  if ( region == -1 ) region =0 ;
76  else if ( region >1 ) std::cout<<"Title)Alert! Region must be -1 or 1 : "<<region<<std::endl;
77  return string("Region ")+regionLabel[region];
78 }
79 
81  vector<string> stationLabel;
82  if ( nstationForLabel == 2) {
83  string stationLabel[] = {"1","2"};
84  return stationLabel[i-1];
85  }
86  else {
87  std::cout<<"Something is wrong"<<std::endl;
88  return "";
89  }
90 }
91 
92 
93 
94 
96 }
97 
99  std::vector<double> xbins_vector;
100  double station1_xmin = RangeZR_[ 0 ];
101  double station1_xmax = RangeZR_[ 1 ];
102  double station2_xmin = RangeZR_[ 2 ];
103  double station2_xmax = RangeZR_[ 3 ];
104 
105  for( double i= station1_xmin-1 ; i< station2_xmax+1; i=i+0.25 ) {
106  if ( i > station1_xmax+1 && i<station2_xmin-1 ) continue;
107  xbins_vector.push_back(i);
108  }
109  TH2F* simpleZR_temp = new TH2F(title,histname, xbins_vector.size()-1, (double*)&xbins_vector[0], 50,120,330);
110  MonitorElement* simpleZR = ibooker.book2D( histname, simpleZR_temp);
111  return simpleZR;
112 }
113 
114 MonitorElement* GEMBaseValidation::getDCEta(DQMStore::IBooker& ibooker, const GEMStation* station, TString title, TString histname ) {
115  if( station->rings().front()->superChambers().size() == 0 ) {
116  LogDebug("MuonBaseValidation")<<"+++ Error! can not get superChambers. Skip "<<getSuffixTitle(station->region(), station->station())<<" on "<<histname<<"\n";
117  return nullptr;
118  }
119 
120 // int nXbins = station->rings().front()->nSuperChambers()*2; //Fine for the complete geometry, but not for the Slice Test geometry
121  int nXbins = 72; //Maximum number of chambers is for GE1/1
122  int nYbins = station->rings().front()->superChambers().front()->chambers().front()->nEtaPartitions();
123 
124  TH2F* dcEta_temp = new TH2F(title,histname,nXbins, 0, nXbins, nYbins, 1, nYbins+1);
125  int idx = 0 ;
126 
127 // for(unsigned int sCh = 1; sCh <= station->superChambers().size(); sCh++){
128  for(unsigned int sCh = 1; sCh <= 36; sCh++){
129  for(unsigned int Ch = 1; Ch <= 2; Ch++){
130  idx++;
131  TString label = TString::Format("ch%d_la%d", sCh, Ch);
132  dcEta_temp->GetXaxis()->SetBinLabel(idx, label.Data());
133  }
134  }
135  MonitorElement* dcEta = ibooker.book2D( histname, dcEta_temp);
136  return dcEta;
137 }
138 
139 
140 MonitorElement* GEMBaseValidation::BookHistZR( DQMStore::IBooker& ibooker, const char* name, const char* label, unsigned int region_num, unsigned int station_num, unsigned int layer_num) {
141  string hist_name, hist_title;
142  if ( layer_num == 0 || layer_num==1 ) {
143  hist_name = name+string("_zr") + getSuffixName(region_num, station_num+1, layer_num+1);
144  hist_title = label+string(" occupancy : region")+getSuffixTitle( region_num, station_num+1, layer_num+1)+" ; globalZ[cm] ; globalR[cm]";
145  }
146  else {
147  hist_name = name+string("_zr") + getSuffixName(region_num, station_num+1);
148  hist_title = label+string(" occupancy : region")+getSuffixTitle( region_num, station_num+1)+" ; globalZ[cm] ; globalR[cm]";
149  }
150  LogDebug("GEMBaseValidation")<<hist_name<<" "<<hist_title<<std::endl;
151  int xbin = (int)nBinZR_[station_num];
152  int ybin = (int)nBinZR_[ nBinZR_.size()/2+station_num];
153  double xmin = 0;
154  double xmax = 0;
155  double ymin = 0;
156  double ymax = 0;
157  ymin = RangeZR_[ RangeZR_.size()/2 + station_num*2 + 0];
158  ymax = RangeZR_[ RangeZR_.size()/2 + station_num*2 + 1];
159  if ( region_num ==0 ) {
160  xmin = -RangeZR_[ station_num*2 + 1];
161  xmax = -RangeZR_[ station_num*2 + 0];
162  }
163  else {
164  xmin = RangeZR_[ station_num*2 + 0];
165  xmax = RangeZR_[ station_num*2 + 1];
166  }
167  return ibooker.book2D( hist_name, hist_title, xbin, xmin, xmax, ybin,ymin, ymax);
168 }
169 
170 MonitorElement* GEMBaseValidation::BookHistXY( DQMStore::IBooker& ibooker, const char* name, const char* label, unsigned int region_num, unsigned int station_num, unsigned int layer_num) {
171  string hist_name, hist_title;
172  if ( layer_num == 0 || layer_num==1 ) {
173  hist_name = name+string("_xy") + getSuffixName( region_num, station_num+1, layer_num+1) ;
174  hist_title = label+string(" occupancy : ")+getSuffixTitle( region_num, station_num+1, layer_num+1 )+ " ; globalX [cm]; globalY[cm]";
175  }
176  else {
177  hist_name = name+string("_xy") + getSuffixName( region_num, station_num+1);
178  hist_title = label+string(" occupancy : region")+getSuffixTitle( region_num, station_num+1) +" ; globalX [cm]; globalY[cm]";
179  }
180  return ibooker.book2D( hist_name, hist_title, nBinXY_, -360,360,nBinXY_,-360,360);
181 }
182 
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
virtual ~GEMBaseValidation()
MonitorElement * BookHistZR(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int station_num, unsigned int layer_num=99)
int region() const
Get the region.
Definition: GEMStation.cc:85
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)
double npart
Definition: HydjetWrapper.h:49
int station() const
Get the station.
Definition: GEMStation.cc:89
std::string getSuffixTitle(int region, int station, int layer)
const GEMGeometry * initGeometry(const edm::EventSetup &)
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
GEMBaseValidation(const edm::ParameterSet &ps)
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:63
const std::vector< const GEMSuperChamber * > & superChambers() const
Return a vector of all GEM super chambers.
Definition: GEMGeometry.cc:55
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const T & get() const
Definition: EventSetup.h:55
MonitorElement * getDCEta(DQMStore::IBooker &, const GEMStation *, TString, TString)
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:59
std::string getStationLabel(int i)
const std::vector< const GEMRing * > & rings() const
Return the rings in the station.
Definition: GEMStation.cc:69