00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef MUONIDHELPERS_RPCIDHELPER_H
00011 #define MUONIDHELPERS_RPCIDHELPER_H
00012
00013
00014
00015 #include "MuonIdHelpers/MuonIdHelper.h"
00016 class MsgStream;
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 class RpcIdHelper : public MuonIdHelper
00058 {
00059 public:
00060
00061
00062
00063 RpcIdHelper();
00064
00065
00066
00067 virtual ~RpcIdHelper();
00068
00070
00072 virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr);
00073 virtual int get_module_hash (const Identifier& id,
00074 IdentifierHash& hash_id ) const;
00075 virtual int get_detectorElement_hash (const Identifier& id,
00076 IdentifierHash& hash_id ) const;
00077
00079
00080
00081
00082 Identifier elementID(int stationName, int stationEta, int stationPhi,
00083 int doubletR, bool check=false, bool* isValid=0) const;
00084 Identifier elementID(std::string stationNameStr, int stationEta,
00085 int stationPhi, int doubletR, bool check=false, bool* isValid=0) const;
00086 Identifier elementID(const Identifier& elementID, int doubletR, bool check=false, bool* isValid=0) const;
00087 Identifier elementID(const Identifier& channelID) const;
00088 Identifier channelID(int stationName, int stationEta, int stationPhi,
00089 int doubletR, int doubletZ, int doubletPhi,
00090 int gasGap, int measuresPhi, int strip, bool check=false, bool* isValid=0) const;
00091 Identifier channelID(std::string stationNameStr, int stationEta,
00092 int stationPhi, int doubletR, int doubletZ,
00093 int doubletPhi, int gasGap, int measuresPhi, int strip, bool check=false, bool* isValid=0) const;
00094 Identifier channelID(const Identifier& id, int doubletZ, int doubletPhi,
00095 int gasGap, int measuresPhi, int strip, bool check=false, bool* isValid=0) const;
00096
00097 Identifier parentID (const Identifier& id) const;
00098 Identifier doubletZID(const Identifier& id) const;
00099
00100 Identifier padID (const Identifier& elementID, int doubletZ, int doubletPhi, bool check=false, bool* isValid=0) const;
00101 Identifier padID (int stationName, int stationEta, int stationPhi, int doubletR,
00102 int doubletZ, int doubletPhi, bool check=false, bool* isValid=0) const;
00103
00104 Identifier panelID (const Identifier& padID, int gasGap, int measuresPhi, bool check=false, bool* isValid=0) const;
00105 Identifier panelID (const Identifier& channelID) const;
00106 Identifier panelID (int stationName, int stationEta, int stationPhi, int doubletR,
00107 int doubletZ, int doubletPhi,int gasGap, int measuresPhi, bool check=false, bool* isValid=0) const;
00108
00109 Identifier gapID (const Identifier& padID, int gasGap, bool check=false, bool* isValid=0) const;
00110 Identifier gapID (const Identifier& panelID) const;
00111 Identifier gapID (int stationName, int stationEta, int stationPhi, int doubletR,
00112 int doubletZ, int doubletPhi,int gasGap, bool check=false, bool* isValid=0) const;
00113
00114
00115
00116
00117 void idChannels (const Identifier& id, std::vector<Identifier>& vect) const;
00118
00119
00120
00121 int channel(const Identifier& id) const;
00122
00123 int doubletR(const Identifier& id) const;
00124 int doubletZ(const Identifier& id) const;
00125 int doubletPhi(const Identifier& id) const;
00126 int gasGap(const Identifier& id) const;
00127 bool measuresPhi(const Identifier& id) const;
00128 int strip(const Identifier& id) const;
00129
00130
00131
00132 int stationEtaMin() const;
00133 int stationEtaMax() const;
00134 int stationPhiMin() const;
00135 int stationPhiMax() const;
00136 int doubletRMin() const;
00137 int doubletRMax() const;
00138 int doubletZMin() const;
00139 int doubletZMax() const;
00140 int doubletPhiMin() const;
00141 int doubletPhiMax() const;
00142 int gasGapMin() const;
00143 int gasGapMax() const;
00144 int measuresPhiMin() const;
00145 int measuresPhiMax() const;
00146 int stripMin() const;
00147 int stripMax() const;
00148
00149
00150
00151 int stationEtaMin (const Identifier& id) const;
00152 int stationEtaMax (const Identifier& id) const;
00153 int stationPhiMin (const Identifier& id) const;
00154 int stationPhiMax (const Identifier& id) const;
00155 int doubletRMin (const Identifier& id) const;
00156 int doubletRMax (const Identifier& id) const;
00157 int doubletZMin (const Identifier& id) const;
00158 int doubletZMax (const Identifier& id) const;
00159 int doubletPhiMin (const Identifier& id) const;
00160 int doubletPhiMax (const Identifier& id) const;
00161 int gasGapMin (const Identifier& id) const;
00162 int gasGapMax (const Identifier& id) const;
00163 int measuresPhiMin(const Identifier& id) const;
00164 int measuresPhiMax(const Identifier& id) const;
00165 int stripMin (const Identifier& id) const;
00166 int stripMax (const Identifier& id) const;
00167
00168
00169
00170 bool valid(const Identifier& id) const;
00171 bool validElement(const Identifier& id) const;
00172 bool validPad(const Identifier& id) const;
00173
00174 private:
00175
00176 virtual int init_detectorElement_hashes(void);
00177 int init_id_to_hashes();
00178 int zIndex(const Identifier& id) const;
00179 int zIndex(std::string name, int eta, int dR, int dZ, int dP) const;
00180 unsigned int m_module_hashes[60][20][8][2];
00181 unsigned int m_detectorElement_hashes[60][20][8][2][4];
00182
00183
00184 size_type m_DOUBLETR_INDEX;
00185 size_type m_DOUBLETZ_INDEX;
00186 size_type m_DOUBLETPHI_INDEX;
00187 size_type m_GASGAP_INDEX;
00188 size_type m_MEASURESPHI_INDEX;
00189
00190 IdDictFieldImplementation m_dbr_impl;
00191 IdDictFieldImplementation m_dbz_impl;
00192 IdDictFieldImplementation m_dbp_impl;
00193 IdDictFieldImplementation m_gap_impl;
00194 IdDictFieldImplementation m_mea_impl;
00195 IdDictFieldImplementation m_str_impl;
00196
00197
00198
00199
00200 bool validElement(const Identifier& id, int stationName, int stationEta,
00201 int stationPhi,int doubletR) const;
00202 bool validChannel(const Identifier& id, int stationName, int stationEta,
00203 int stationPhi,int doubletR, int doubletZ,
00204 int doubletPhi, int gasGap,int measuresPhi,
00205 int strip) const;
00206 bool validPad (const Identifier& id, int stationName, int stationEta,
00207 int stationPhi,int doubletR, int doubletZ,
00208 int doubletPhi) const;
00209
00210
00211
00212 int rpcTechnology() const;
00213
00214
00215
00216 enum RpcIndices
00217 {
00218 DoubletRIndex = 5,
00219 DoubletZIndex = 6,
00220 DoubletPhiIndex = 7,
00221 GasGapIndex = 8,
00222 MeasuresPhiIndex = 9,
00223 StripIndex = 10
00224 };
00225
00226
00227
00228 enum RpcRanges
00229 {
00230 StationEtaMin = -8,
00231 StationEtaMax = 8,
00232 StationPhiMin = 1,
00233 StationPhiMax = 8,
00234 DoubletRMin = 1,
00235 DoubletRMax = 2,
00236 DoubletZMin = 1,
00237 DoubletZMax = 3,
00238 DoubletPhiMin = 1,
00239 DoubletPhiMax = 2,
00240 GasGapMin = 1,
00241 GasGapMax = 4,
00242 MeasuresPhiMin = 0,
00243 MeasuresPhiMax = 1,
00244 StripMin = 1,
00245 StripMax = 99
00246 };
00247 inline virtual void create_mlog() const;
00248
00249 };
00250
00251
00252
00253 typedef RpcIdHelper RPC_ID;
00254
00255 CLASS_DEF(RpcIdHelper, 4172, 1)
00256
00257
00258
00259 inline Identifier RpcIdHelper::elementID(int stationName, int stationEta, int stationPhi,
00260 int doubletR, bool check, bool* isValid) const {
00261
00262
00263 Identifier result((Identifier::value_type)0);
00264 bool val = false;
00265 m_muon_impl.pack(muon_field_value(),result);
00266 m_sta_impl.pack (stationName,result);
00267 m_eta_impl.pack (stationEta,result);
00268 m_phi_impl.pack (stationPhi,result);
00269 m_tec_impl.pack (rpc_field_value(),result);
00270 m_dbr_impl.pack (doubletR,result);
00271 if ( check ) {
00272 val = this->validElement(result,stationName,stationEta,
00273 stationPhi,doubletR);
00274 if ( isValid ) *isValid = val;
00275 }
00276 return result;
00277
00278 }
00279
00280 inline Identifier RpcIdHelper::elementID(std::string stationNameStr, int stationEta,
00281 int stationPhi, int doubletR, bool check, bool* isValid) const {
00282
00283 Identifier id;
00284 int stationName = stationNameIndex(stationNameStr);
00285 id = elementID(stationName, stationEta, stationPhi, doubletR, check, isValid);
00286 return id;
00287 }
00288
00289 inline Identifier RpcIdHelper::elementID(const Identifier& id, int doubletR, bool check, bool* isValid) const {
00290
00291 Identifier result(id);
00292 bool val = false;
00293 m_dbr_impl.pack(doubletR,result);
00294 if ( check ) {
00295 val = this->validElement(result);
00296 if ( isValid ) *isValid = val;
00297 }
00298
00299 return result;
00300
00301 }
00302
00303 inline Identifier RpcIdHelper::elementID(const Identifier& id) const
00304 {
00305 return parentID(id);
00306 }
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 inline Identifier RpcIdHelper::panelID(int stationName, int stationEta, int stationPhi,
00318 int doubletR, int doubletZ, int doubletPhi,
00319 int gasGap, int measuresPhi,
00320 bool check, bool* isValid) const
00321 {
00322
00323
00324 Identifier result((Identifier::value_type)0);
00325 bool val = false;
00326 m_muon_impl.pack(muon_field_value(),result);
00327 m_sta_impl.pack (stationName,result);
00328 m_eta_impl.pack (stationEta,result);
00329 m_phi_impl.pack (stationPhi,result);
00330 m_tec_impl.pack (rpc_field_value(),result);
00331 m_dbr_impl.pack (doubletR,result);
00332 m_dbz_impl.pack (doubletZ,result);
00333 m_dbp_impl.pack (doubletPhi,result);
00334 m_gap_impl.pack (gasGap,result);
00335 m_mea_impl.pack (measuresPhi,result);
00336 if ( check ) {
00337 val = this->valid(result);
00338 if ( isValid ) *isValid = val;
00339 }
00340 return result;
00341
00342 }
00343
00344
00345
00346 inline Identifier RpcIdHelper::panelID(const Identifier& channelID) const
00347 {
00348
00349 Identifier result(channelID);
00350 m_str_impl.reset(result);
00351 return result;
00352
00353 }
00354
00355 inline Identifier RpcIdHelper::panelID(const Identifier& padID, int gasGap, int measuresPhi,bool check, bool* isValid) const
00356 {
00357
00358 Identifier result(padID);
00359 bool val = false;
00360 m_gap_impl.pack (gasGap,result);
00361 m_mea_impl.pack (measuresPhi,result);
00362 if ( check ) {
00363 val = this->valid(result);
00364 if ( isValid ) *isValid = val;
00365 }
00366 return result;
00367
00368 }
00369
00370
00371 inline Identifier RpcIdHelper::gapID(int stationName, int stationEta, int stationPhi,
00372 int doubletR, int doubletZ, int doubletPhi,
00373 int gasGap,
00374 bool check, bool* isValid) const
00375 {
00376
00377
00378 Identifier result((Identifier::value_type)0);
00379 bool val = false;
00380 m_muon_impl.pack(muon_field_value(),result);
00381 m_sta_impl.pack (stationName,result);
00382 m_eta_impl.pack (stationEta,result);
00383 m_phi_impl.pack (stationPhi,result);
00384 m_tec_impl.pack (rpc_field_value(),result);
00385 m_dbr_impl.pack (doubletR,result);
00386 m_dbz_impl.pack (doubletZ,result);
00387 m_dbp_impl.pack (doubletPhi,result);
00388 m_gap_impl.pack (gasGap,result);
00389 if ( check ) {
00390 val = this->valid(result);
00391 if ( isValid ) *isValid = val;
00392 }
00393 return result;
00394
00395 }
00396
00397
00398 inline Identifier RpcIdHelper::gapID(const Identifier& panelID) const
00399 {
00400
00401 Identifier result(panelID);
00402 m_mea_impl.reset(result);
00403 return result;
00404
00405 }
00406
00407 inline Identifier RpcIdHelper::gapID(const Identifier& padID, int gasGap,bool check, bool* isValid) const
00408 {
00409
00410 Identifier result(padID);
00411 bool val = false;
00412 m_gap_impl.pack (gasGap,result);
00413 if ( check ) {
00414 val = this->valid(result);
00415 if ( isValid ) *isValid = val;
00416 }
00417 return result;
00418
00419 }
00420
00421
00422
00423
00424
00425 inline Identifier RpcIdHelper::channelID(int stationName, int stationEta, int stationPhi,
00426 int doubletR, int doubletZ, int doubletPhi,
00427 int gasGap, int measuresPhi, int strip,
00428 bool check, bool* isValid) const
00429 {
00430
00431
00432 Identifier result((Identifier::value_type)0);
00433 bool val = false;
00434 m_muon_impl.pack(muon_field_value(),result);
00435 m_sta_impl.pack (stationName,result);
00436 m_eta_impl.pack (stationEta,result);
00437 m_phi_impl.pack (stationPhi,result);
00438 m_tec_impl.pack (rpc_field_value(),result);
00439 m_dbr_impl.pack (doubletR,result);
00440 m_dbz_impl.pack (doubletZ,result);
00441 m_dbp_impl.pack (doubletPhi,result);
00442 m_gap_impl.pack (gasGap,result);
00443 m_mea_impl.pack (measuresPhi,result);
00444 m_str_impl.pack (strip,result);
00445 if ( check ) {
00446 val = this->validChannel(result,stationName,stationEta,
00447 stationPhi,doubletR,doubletZ,
00448 doubletPhi,gasGap,measuresPhi,strip);
00449 if ( isValid ) *isValid = val;
00450 }
00451 return result;
00452
00453 }
00454
00455 inline Identifier RpcIdHelper::channelID(std::string stationNameStr, int stationEta,
00456 int stationPhi, int doubletR, int doubletZ,
00457 int doubletPhi, int gasGap, int measuresPhi,
00458 int strip, bool check, bool* isValid) const {
00459
00460 Identifier id;
00461 int stationName = stationNameIndex(stationNameStr);
00462 id = channelID(stationName, stationEta, stationPhi, doubletR, doubletZ,
00463 doubletPhi, gasGap, measuresPhi, strip, check, isValid);
00464 return id;
00465 }
00466
00467 inline Identifier RpcIdHelper::channelID(const Identifier& id,
00468 int doubletZ, int doubletPhi, int gasGap,
00469 int measuresPhi, int strip, bool check, bool* isValid) const {
00470
00471
00472 Identifier result(id);
00473 bool val = false;
00474 m_dbz_impl.pack (doubletZ,result);
00475 m_dbp_impl.pack (doubletPhi,result);
00476 m_gap_impl.pack (gasGap,result);
00477 m_mea_impl.pack (measuresPhi,result);
00478 m_str_impl.pack (strip,result);
00479 if ( check ) {
00480 val = this->valid(result);
00481 if ( isValid ) *isValid = val;
00482 }
00483 return result;
00484 }
00485
00486
00487 inline Identifier RpcIdHelper::parentID(const Identifier& id) const {
00488 assert(is_rpc(id));
00489 Identifier result(id);
00490 m_dbz_impl.reset(result);
00491 m_dbp_impl.reset(result);
00492 m_gap_impl.reset(result);
00493 m_mea_impl.reset(result);
00494 m_str_impl.reset(result);
00495 return result;
00496 }
00497
00498
00499 inline Identifier RpcIdHelper::doubletZID(const Identifier& id) const {
00500 assert(is_rpc(id));
00501 Identifier result(id);
00502 m_dbp_impl.reset(result);
00503 m_gap_impl.reset(result);
00504 m_mea_impl.reset(result);
00505 m_str_impl.reset(result);
00506 return result;
00507 }
00508
00509 inline Identifier RpcIdHelper::padID(int stationName, int stationEta, int stationPhi,
00510 int doubletR, int doubletZ, int doubletPhi, bool check, bool* isValid) const
00511 {
00512
00513 Identifier result((Identifier::value_type)0);
00514 bool val = false;
00515 m_muon_impl.pack(muon_field_value(),result);
00516 m_sta_impl.pack (stationName,result);
00517 m_eta_impl.pack (stationEta,result);
00518 m_phi_impl.pack (stationPhi,result);
00519 m_tec_impl.pack (rpc_field_value(),result);
00520 m_dbr_impl.pack (doubletR,result);
00521 m_dbz_impl.pack (doubletZ,result);
00522 m_dbp_impl.pack (doubletPhi,result);
00523 if ( check ) {
00524 val = this->validPad(result,stationName,stationEta,
00525 stationPhi,doubletR,doubletZ,doubletPhi);
00526 if ( isValid ) *isValid = val;
00527 }
00528 return result;
00529
00530 }
00531
00532 inline Identifier RpcIdHelper::padID(const Identifier& id,
00533 int doubletZ, int doubletPhi, bool check, bool* isValid) const {
00534
00535
00536 Identifier result(id);
00537 bool val = false;
00538 m_dbz_impl.pack (doubletZ,result);
00539 m_dbp_impl.pack (doubletPhi,result);
00540 if ( check ) {
00541 val = this->validPad(result);
00542 if ( isValid ) *isValid = val;
00543 }
00544 return result;
00545
00546 }
00547
00548
00549
00550 inline int RpcIdHelper::doubletR(const Identifier& id) const {
00551
00552 return m_dbr_impl.unpack(id);
00553
00554 }
00555
00556 inline int RpcIdHelper::doubletZ(const Identifier& id) const {
00557
00558 return m_dbz_impl.unpack(id);
00559
00560 }
00561
00562 inline int RpcIdHelper::doubletPhi(const Identifier& id) const {
00563
00564 return m_dbp_impl.unpack(id);
00565
00566 }
00567
00568 inline int RpcIdHelper::gasGap(const Identifier& id) const {
00569
00570 return m_gap_impl.unpack(id);
00571
00572 }
00573
00574 inline bool RpcIdHelper::measuresPhi(const Identifier& id) const {
00575
00576 return m_mea_impl.unpack(id);
00577
00578 }
00579
00580 inline int RpcIdHelper::strip(const Identifier& id) const {
00581
00582 return m_str_impl.unpack(id);
00583
00584 }
00585
00586 inline int RpcIdHelper::channel(const Identifier& id) const {
00587
00588 return strip(id);
00589
00590 }
00591
00592
00593
00594 inline int RpcIdHelper::stationEtaMin() const
00595 {
00596 return StationEtaMin;
00597 }
00598
00599 inline int RpcIdHelper::stationEtaMax() const
00600 {
00601 return StationEtaMax;
00602 }
00603
00604 inline int RpcIdHelper::stationPhiMin() const
00605 {
00606 return StationPhiMin;
00607 }
00608
00609 inline int RpcIdHelper::stationPhiMax() const
00610 {
00611 return StationPhiMax;
00612 }
00613
00614 inline int RpcIdHelper::doubletRMin() const
00615 {
00616 return DoubletRMin;
00617 }
00618
00619 inline int RpcIdHelper::doubletRMax() const
00620 {
00621 return DoubletRMax;
00622 }
00623
00624 inline int RpcIdHelper::doubletZMin() const
00625 {
00626 return DoubletZMin;
00627 }
00628
00629 inline int RpcIdHelper::doubletZMax() const
00630 {
00631 return DoubletZMax;
00632 }
00633
00634 inline int RpcIdHelper::doubletPhiMin() const
00635 {
00636 return DoubletPhiMin;
00637 }
00638
00639 inline int RpcIdHelper::doubletPhiMax() const
00640 {
00641 return DoubletPhiMax;
00642 }
00643
00644 inline int RpcIdHelper::gasGapMin() const
00645 {
00646 return GasGapMin;
00647 }
00648
00649 inline int RpcIdHelper::gasGapMax() const
00650 {
00651 return GasGapMax;
00652 }
00653
00654 inline int RpcIdHelper::measuresPhiMin() const
00655 {
00656 return MeasuresPhiMin;
00657 }
00658
00659 inline int RpcIdHelper::measuresPhiMax() const
00660 {
00661 return MeasuresPhiMax;
00662 }
00663
00664 inline int RpcIdHelper::stripMin() const
00665 {
00666 return StripMin;
00667 }
00668
00669 inline int RpcIdHelper::stripMax() const
00670 {
00671 return StripMax;
00672 }
00673
00675
00676 inline int RpcIdHelper::rpcTechnology() const
00677 {
00678 int rpcField = technologyIndex("RPC");
00679 if (m_dict)
00680 {
00681 rpcField = rpc_field_value();
00682 }
00683 return rpcField;
00684 }
00685
00686 inline int RpcIdHelper::zIndex(const Identifier& id) const {
00687 int station = stationName(id);
00688 int eta = stationEta(id);
00689 int dR = doubletR(id);
00690 int dZ = doubletZ(id);
00691 int dP = doubletPhi(id);
00692 std::string name = stationNameString(station);
00693 return zIndex(name, eta, dR, dZ, dP);
00694 }
00695
00696 inline int RpcIdHelper::zIndex(std::string name, int eta, int dR, int dZ, int dP) const {
00697
00723 int dbz_index = dZ;
00724
00725 if ( name == "BMS" ) {
00726 if (abs(eta) == 2 && dZ ==3 )
00727 {
00728 if (dP == 2) dbz_index++;
00729 }
00730 else if (abs(eta) == 4 && dR==2 && dZ==3)
00731 {
00732 if (dP == 2) dbz_index++;
00733 }
00734 else if (abs(eta) == 4 && dR==1 && dZ==2)
00735 {
00736 if (dP == 2) dbz_index++;
00737 }
00738 }
00739 return dbz_index;
00740 }
00741
00742 #endif // MUONIDHELPERS_RPCIDHELPER_H
00743