Go to the documentation of this file.00001 #ifndef rpcdqm_utils_H
00002 #define rpcdqm_utils_H
00003
00004 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00005 #include "DQMServices/Core/interface/MonitorElement.h"
00006
00007 #include <vector>
00008 #include <iomanip>
00009 #include <string>
00010
00011
00012 namespace rpcdqm{
00013
00014 enum RPCMeFLag{OCCUPANCY = 1, CLUSTERSIZE = 2, MULTIPLICITY =3};
00015
00016 class utils{
00017 public:
00018 int detId2RollNr(const RPCDetId & _id){
00019 if(_id.region()==0){
00020 if( _id.station() ==1) {
00021 if(_id.layer() ==1) {
00022 if(_id.roll()==1)
00023 _cnr = 1;
00024 else
00025 _cnr = 2;
00026 } else {
00027 if(_id.roll()==1)
00028 _cnr = 3;
00029 else
00030 _cnr = 4;
00031 }
00032 }else if (_id.station()==2) {
00033 if(_id.layer()==1) {
00034 if(_id.roll()==1)
00035 _cnr = 5;
00036 else if(_id.roll()==3)
00037 _cnr=6;
00038 else if(_id.roll()==2)
00039 _cnr=7;
00040 }else{
00041 if(_id.roll()==2)
00042 _cnr=7;
00043 else if(_id.roll()==1)
00044 _cnr=8;
00045 else if(_id.roll()==3)
00046 _cnr=9;
00047 }
00048 }else if(_id.station()==3){
00049 if(_id.subsector()==1){
00050 if(_id.roll()==1)
00051 _cnr=10;
00052 else
00053 _cnr=11;
00054 } else {
00055 if(_id.roll()==1)
00056 _cnr=12;
00057 else
00058 _cnr=13;
00059 }
00060 } else if(_id.station()==4) {
00061 if (_id.sector()== 4) {
00062 if ( _id.subsector()==2){
00063 if(_id.roll()==1)
00064 _cnr=14;
00065 else
00066 _cnr=15;
00067 }else if (_id.subsector()==3){
00068 if(_id.roll()==1)
00069 _cnr=16;
00070 else
00071 _cnr=17;
00072 }else if ( _id.subsector()==1) {
00073 if(_id.roll()==1)
00074 _cnr=18;
00075 else
00076 _cnr=19;
00077 }else if ( _id.subsector()==4){
00078 if(_id.roll()==1)
00079 _cnr=20;
00080 else
00081 _cnr=21;
00082 }
00083 } else {
00084 if(_id.subsector()==1) {
00085 if(_id.roll()==1)
00086 _cnr=14;
00087 else
00088 _cnr=15;
00089 } else {
00090 if(_id.roll()==1)
00091 _cnr=16;
00092 else
00093 _cnr=17;
00094 }
00095 }
00096 }
00097 }else{
00098 int nseg=36;
00099 int nsub=6;
00100 if ( _id.ring()==1 && _id.station() > 1) {
00101 nsub=3;
00102 nseg=18;
00103 }
00104 _cnr = (_id.subsector()-1)*3+_id.roll()+(_id.ring()-1)*nsub*3;
00105 }
00106 return _cnr;
00107 }
00108
00109 void fillvect() {
00110 Wvector2.push_back(0);
00111 Wvector2.push_back(1140);
00112 Wvector2.push_back(1140);
00113 Wvector2.push_back(1140);
00114 Wvector2.push_back(1236);
00115 Wvector2.push_back(1140);
00116 Wvector2.push_back(1140);
00117 Wvector2.push_back(1140);
00118 Wvector2.push_back(1116);
00119 Wvector2.push_back(1044);
00120 Wvector2.push_back(1188);
00121 Wvector2.push_back(1044);
00122 Wvector2.push_back(1166);
00123
00124 Wvector1.push_back(0);
00125 Wvector1.push_back(1146);
00126 Wvector1.push_back(1146);
00127 Wvector1.push_back(1146);
00128 Wvector1.push_back(1242);
00129 Wvector1.push_back(1146);
00130 Wvector1.push_back(1146);
00131 Wvector1.push_back(1146);
00132 Wvector1.push_back(1122);
00133 Wvector1.push_back(1050);
00134 Wvector1.push_back(1194);
00135 Wvector1.push_back(1050);
00136 Wvector1.push_back(1122);
00137
00138 }
00139
00140 std::vector<int> SectorStrips2(){
00141 return Wvector2;
00142 }
00143
00144 std::vector<int> SectorStrips1(){
00145 return Wvector1;
00146 }
00147
00148
00149 void dolabeling () {
00150
00151 ylabel[1] = "RB1in_B";
00152 ylabel[2] = "RB1in_F";
00153 ylabel[3] = "RB1out_B";
00154 ylabel[4] = "RB1out_F";
00155 ylabel[5] = "RB2in_B";
00156 ylabel[6] = "RB2in_F";
00157
00158 ylabel[7] = "RB2in_M";
00159 ylabel[0] = "RB2out_M";
00160
00161 ylabel[8] = "RB2out_B";
00162 ylabel[9] = "RB2out_F";
00163 ylabel[10] = "RB3-_B";
00164 ylabel[11] = "RB3-_F";
00165 ylabel[12] = "RB3+_B";
00166 ylabel[13] = "RB3+_F";
00167 ylabel[14] = "RB4,-_B";
00168 ylabel[15] = "RB4,-_F";
00169 ylabel[16] = "RB4+_B";
00170 ylabel[17] = "RB4+_F";
00171 ylabel[18] = "RB4--_B";
00172 ylabel[19] = "RB4--_F";
00173 ylabel[20] = "RB4++_B";
00174 ylabel[21] = "RB4++_F";
00175 }
00176
00177
00178 void doEndcapLabeling(){
00179
00180 std::string rolls[3];
00181 rolls[0]="A";
00182 rolls[1]="B";
00183 rolls[2]="C";
00184
00185 endcapYLabels_.clear();
00186 std::stringstream myLabel;
00187
00188 for(int ring = 1 ; ring <=3; ring ++){
00189 for(int ch = 1; ch<=6; ch++){
00190 for(int r=0; r<3; r++){
00191 myLabel.str("");
00192 myLabel<<"R"<<ring<<"_C"<<ch<<"_"<<rolls[r];
00193 endcapYLabels_.push_back(myLabel.str());
00194 }
00195 }
00196 }
00197 }
00198
00199 std::string YLabel(int i) {
00200
00201 return ylabel[i];
00202
00203 }
00204
00205
00206 void labelXAxisSector(MonitorElement * myMe){
00207
00208 if (!myMe) return;
00209
00210 std::stringstream xLabel;
00211
00212 for(int x = 1; x<= myMe->getNbinsX(); x++){
00213 xLabel.str("");
00214 xLabel<<"Sec"<<x;
00215 myMe->setBinLabel(x, xLabel.str(), 1);
00216 }
00217
00218 }
00219
00220
00221 void labelXAxisSegment(MonitorElement * myMe){
00222
00223 if (!myMe) return;
00224
00225 std::stringstream xLabel;
00226
00227 myMe->setAxisTitle("Segments", 1);
00228
00229 for(int x = 1; x<= myMe->getNbinsX(); x++){
00230 xLabel.str("");
00231 xLabel<<x;
00232 myMe->setBinLabel(x, xLabel.str(), 1);
00233 }
00234
00235 }
00236
00237
00238
00239 void labelYAxisRoll(MonitorElement * myMe, int region, int ring){
00240
00241
00242 if (!myMe) return;
00243
00244
00245 if(region == 0){
00246
00247
00248 this->dolabeling();
00249 if(ring == -2 || ring == 2) ylabel[7]=ylabel[0];
00250
00251 for(int y = 1; y<= myMe->getNbinsY() && y<22; y++)
00252 myMe->setBinLabel(y, ylabel[y], 2);
00253
00254 }else{
00255
00256 this->doEndcapLabeling();
00257
00258 for(int y = 1; y<= myMe->getNbinsY() && y<(int)endcapYLabels_.size(); y++)
00259 myMe->setBinLabel(y, endcapYLabels_[y], 2);
00260
00261 }
00262 }
00263
00264
00265
00266 void labelYAxisRing(MonitorElement * myMe, int numberOfRings){
00267
00268
00269 if (!myMe) return;
00270
00271 std::string labels[9]= {"C", "Ring1 B", "A","C", "Ring2 B", "A","C", "Ring3 B", "A"};
00272 int startBin ;
00273 (numberOfRings == 2 ? startBin = 3: startBin = 0);
00274
00275
00276 for(int y =1 ;y<= myMe->getNbinsY() && y<=9; y++ )
00277 myMe->setBinLabel(y,labels[y-1+startBin],2);
00278 }
00279
00280
00281
00282 int detId2ChamberNr(const RPCDetId & _id){
00283 if(_id.region()==0){
00284 if( _id.station() ==1) {
00285 if(_id.layer() ==1) {
00286
00287 ch=1;
00288
00289 } else {
00290 ch=2;
00291 }
00292
00293 }else if (_id.station()==2) {
00294 if(_id.layer()==1) {
00295
00296 ch=3;
00297 }else{
00298
00299 ch=4;
00300 }
00301 }else if(_id.station()==3){
00302 if(_id.subsector()==1){
00303 ch=5;
00304 } else {
00305
00306 ch=6;
00307 }
00308 } else if(_id.station()==4) {
00309 if (_id.sector()== 4) {
00310 if ( _id.subsector()==1){
00311
00312 ch=7;
00313
00314 }else if (_id.subsector()==2){
00315 ch=8;
00316 }else if ( _id.subsector()==3) {
00317 ch=9;
00318 }else if ( _id.subsector()==4){
00319 ch=10;
00320 }
00321 } else {
00322 if(_id.subsector()==1) ch= 7;
00323 else ch= 8;
00324 }
00325 }
00326 }else{
00327 }
00328 return ch;
00329 }
00330
00331
00332
00333
00334 std::string detId2ChamberLabel(const RPCDetId & _id){
00335 if(_id.region()==0){
00336 if( _id.station() ==1) {
00337 if(_id.layer() ==1) {
00338
00339 ChLabel="RB1in";
00340
00341 } else {
00342 ChLabel="RB1out";
00343 }
00344
00345 }else if (_id.station()==2) {
00346 if(_id.layer()==1) {
00347
00348 ChLabel="RB2in";
00349 }else{
00350
00351 ChLabel="RB2out";
00352 }
00353 }else if(_id.station()==3){
00354 if(_id.subsector()==1){
00355 ChLabel="RB3+";
00356 } else {
00357
00358 ChLabel="RB3-";
00359 }
00360 } else if(_id.station()==4) {
00361 if (_id.sector()== 4) {
00362 if ( _id.subsector()==1){
00363
00364 ChLabel="RB4-";
00365
00366 }else if (_id.subsector()==2){
00367 ChLabel="RB4+";
00368 }else if ( _id.subsector()==3) {
00369 ChLabel="RB4--";
00370 }else if ( _id.subsector()==4){
00371 ChLabel="RB4++";
00372 }
00373 } else {
00374 if(_id.subsector()==1) ChLabel="RB4-";
00375 else ChLabel="RB4-";
00376 }
00377 }
00378 }else{
00379 }
00380 return ChLabel;
00381 }
00382
00383
00384
00385 private:
00386 int _cnr;
00387 int ch;
00388 std::vector<std::string> endcapYLabels_;
00389 std::string ChLabel;
00390 std::vector<int> Wvector2;
00391 std::vector<int> Wvector1;
00392 std::string ylabel[22];
00393 };
00394 }
00395
00396 #endif