00001
00002
00003
00004
00005
00006
00007
00008 #ifndef MUONIDHELPERS_STGCIDHELPER_H
00009 #define MUONIDHELPERS_STGCIDHELPER_H
00010
00011
00012 class MsgStream;
00013 #include "MuonIdHelpers/MuonIdHelper.h"
00014
00015
00016
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 class sTgcIdHelper : public MuonIdHelper {
00055 public:
00056
00057
00058 sTgcIdHelper();
00059
00060
00061 virtual ~sTgcIdHelper();
00062
00064
00066 virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr);
00067 virtual int get_module_hash(const Identifier& id, IdentifierHash& hash_id ) const;
00068 virtual int get_detectorElement_hash(const Identifier& id, IdentifierHash& hash_id ) const;
00069
00071
00072
00073 Identifier elementID(int stationName, int stationEta, int stationPhi, bool check=false, bool* isValid=0) const;
00074 Identifier elementID(std::string stationNameStr, int stationEta,int stationPhi, bool check=false, bool* isValid=0) const ;
00075 Identifier elementID(const Identifier& channelID) const ;
00076
00077 Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel, bool check=false, bool* isValid=0) const ;
00078 Identifier channelID(std::string stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel, bool check=false, bool* isValid=0) const ;
00079 Identifier channelID(const Identifier& id, int multilayer, int gasGap, int channelType, int channel, bool check=false, bool* isValid=0) const ;
00080
00081 Identifier padID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, int padPhi, bool check=false, bool* isValid=0) const ;
00082 Identifier padID(std::string stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, int padPhi, bool check=false, bool* isValid=0) const ;
00083 Identifier padID(const Identifier& id, int multilayer, int gasGap, int channelType, int padEta, int padPhi, bool check=false, bool* isValid=0) const ;
00084
00085 Identifier parentID (const Identifier& id) const;
00086
00087 Identifier multilayerID(const Identifier& channeldID) const;
00088 Identifier multilayerID(const Identifier& moduleID, int multilayer, bool check=false, bool* isValid=0) const;
00089
00090
00091
00092 void idChannels (const Identifier& id, std::vector<Identifier>& vect) const;
00093
00094
00095 int gasGap(const Identifier& id) const;
00096 int multilayer(const Identifier& id) const;
00097 int channelType(const Identifier& id) const;
00098 bool measuresPhi(const Identifier& id) const;
00099 int channel(const Identifier& id) const;
00100 int numberOfMultilayers(const Identifier& id) const;
00101 int padEta(const Identifier& id) const;
00102 int padPhi(const Identifier& id) const;
00103
00104
00105
00106 int stationEtaMin() const;
00107 int stationEtaMax() const;
00108 int stationPhiMin() const;
00109 int stationPhiMax() const;
00110 int multilayerMin() const;
00111 int multilayerMax() const;
00112 int gasGapMin() const;
00113 int gasGapMax() const;
00114 int channelTypeMin() const;
00115 int channelTypeMax() const;
00116 int channelMin() const;
00117 int channelMax() const;
00118 int padEtaMin() const;
00119 int padEtaMax() const;
00120 int padPhiMin() const;
00121 int padPhiMax() const;
00122
00123
00124
00125 int stationEtaMin (const Identifier& id) const;
00126 int stationEtaMax (const Identifier& id) const;
00127 int stationPhiMin (const Identifier& id) const;
00128 int stationPhiMax (const Identifier& id) const;
00129 int multilayerMin (const Identifier& id) const;
00130 int multilayerMax (const Identifier& id) const;
00131 int gasGapMin (const Identifier& id) const;
00132 int gasGapMax (const Identifier& id) const;
00133 int channelTypeMin (const Identifier& id) const;
00134 int channelTypeMax (const Identifier& id) const;
00135 int channelMin (const Identifier& id) const;
00136 int channelMax (const Identifier& id) const;
00137
00138
00139 bool valid(const Identifier& id) const;
00140 bool validElement(const Identifier& id) const;
00141
00142
00143 enum sTgcChannelTypes {
00144 Pad = 0,
00145 Strip = 1,
00146 Wire = 2
00147 };
00148
00149 private:
00150 int init_id_to_hashes();
00151 unsigned int m_module_hashes[60][20][48];
00152 unsigned int m_detectorElement_hashes[60][20][8][3];
00153
00154
00155 size_type m_GASGAP_INDEX;
00156 size_type m_CHANNELTYPE_INDEX;
00157
00158 IdDictFieldImplementation m_gap_impl;
00159 IdDictFieldImplementation m_typ_impl;
00160 IdDictFieldImplementation m_cha_impl;
00161 IdDictFieldImplementation m_mplet_impl;
00162
00163
00164 bool validElement(const Identifier& id, int stationName, int stationEta, int stationPhi) const;
00165 bool validChannel(const Identifier& id, int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const;
00166 bool validChannel(const Identifier& id, int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, int padPhi) const;
00167
00168
00169 int stgcTechnology() const;
00170 bool LargeSector(int stationName) const;
00171 bool SmallSector(int stationName) const;
00172
00173
00174 enum sTgcIndices {
00175 MultilayerIndex = 5,
00176 GasGapIndex = 6,
00177 ChannelTypeIndex = 7,
00178 ChannelIndex = 8
00179 };
00180
00181
00182 enum sTgcRanges {
00183 StationEtaMin = -4,
00184 StationEtaMax = 4,
00185 StationPhiMin = 1,
00186 StationPhiMax = 8,
00187 MultilayerMin = 1,
00188 MultilayerMax = 2,
00189 GasGapMin = 1,
00190 GasGapMax = 4,
00191 ChannelTypeMin = 0,
00192 ChannelTypeMax = 2,
00193 ChannelMin = 1,
00194 ChannelMax = 315,
00195 PadPhiMin = 1,
00196 PadPhiMax = 8,
00197 PadEtaMin = 1,
00198 PadEtaMax = 20
00199 };
00200 inline virtual void create_mlog() const;
00201 };
00202
00203
00204 typedef sTgcIdHelper sTGC_ID;
00205
00206 CLASS_DEF(sTgcIdHelper, 4174, 1)
00207
00208
00209 inline Identifier sTgcIdHelper::elementID(int stationName, int stationEta, int stationPhi, bool check, bool* isValid) const {
00210
00211 Identifier result((Identifier::value_type)0);
00212 bool val = false;
00213 m_muon_impl.pack(muon_field_value(),result);
00214 m_sta_impl.pack (stationName,result);
00215 m_eta_impl.pack (stationEta,result);
00216 m_phi_impl.pack (stationPhi,result);
00217 m_tec_impl.pack (stgc_field_value(),result);
00218 if ( check ) {
00219 val = this->validElement(result,stationName,stationEta,stationPhi);
00220 if ( isValid ) *isValid = val;
00221 }
00222 return result;
00223 }
00224
00225 inline Identifier sTgcIdHelper::elementID(std::string stationNameStr, int stationEta, int stationPhi, bool check, bool* isValid) const {
00226 Identifier id;
00227 int stationName = stationNameIndex(stationNameStr);
00228 id = elementID(stationName, stationEta, stationPhi, check, isValid);
00229 return id;
00230 }
00231
00232 inline Identifier sTgcIdHelper::elementID(const Identifier& id) const {
00233 return parentID(id);
00234 }
00235
00236 inline Identifier sTgcIdHelper::channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel, bool check, bool* isValid) const {
00237
00238 Identifier result((Identifier::value_type)0);
00239 bool val = false;
00240 m_muon_impl.pack(muon_field_value(),result);
00241 m_sta_impl.pack (stationName,result);
00242 m_eta_impl.pack (stationEta,result);
00243 m_phi_impl.pack (stationPhi,result);
00244 m_tec_impl.pack (stgc_field_value(),result);
00245 m_mplet_impl.pack (multilayer,result);
00246 m_gap_impl.pack (gasGap,result);
00247 m_typ_impl.pack (channelType,result);
00248 m_cha_impl.pack (channel,result);
00249 if ( check ) {
00250 val = validChannel(result,stationName,stationEta,stationPhi,multilayer,gasGap,channelType,channel);
00251 if ( isValid ) *isValid = val;
00252 }
00253 return result;
00254 }
00255
00256 inline Identifier sTgcIdHelper::channelID(std::string stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel, bool check, bool * isValid) const {
00257 Identifier id;
00258 int stationName = stationNameIndex(stationNameStr);
00259 id = channelID(stationName, stationEta, stationPhi, multilayer, gasGap, channelType, channel, check, isValid);
00260 return id;
00261 }
00262
00263 inline Identifier sTgcIdHelper::channelID(const Identifier& id, int multilayer, int gasGap, int channelType, int channel, bool check, bool* isValid) const {
00264 Identifier result = parentID(id);
00265 bool val = false;
00266 m_mplet_impl.pack (multilayer,result);
00267 m_gap_impl.pack (gasGap,result);
00268 m_typ_impl.pack (channelType,result);
00269 m_cha_impl.pack (channel,result);
00270 if ( check ) {
00271 val = this->valid(result);
00272 if ( isValid ) *isValid = val;
00273 }
00274 return result;
00275 }
00276
00277 inline Identifier sTgcIdHelper::padID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, int padPhi, bool check, bool* isValid) const {
00278
00279 Identifier result((Identifier::value_type)0);
00280 bool val = false;
00281 m_muon_impl.pack(muon_field_value(),result);
00282 m_sta_impl.pack (stationName,result);
00283 m_eta_impl.pack (stationEta,result);
00284 m_phi_impl.pack (stationPhi,result);
00285 m_tec_impl.pack (stgc_field_value(),result);
00286 m_mplet_impl.pack (multilayer,result);
00287 m_gap_impl.pack (gasGap,result);
00288 m_typ_impl.pack (channelType,result);
00289 int channel = -1;
00290 if (channelType == Pad) {
00291 channel = (padPhi - 1) * PadEtaMax + padEta;
00292 } else {
00293 *isValid = false;
00294 }
00295 m_cha_impl.pack (channel,result);
00296 if ( check ) {
00297 val = validChannel(result, stationName, stationEta, stationPhi, multilayer, gasGap, channelType, padEta, padPhi);
00298 if ( isValid ) *isValid = val;
00299 }
00300 return result;
00301 }
00302
00303 inline Identifier sTgcIdHelper::padID(std::string stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, int padPhi, bool check, bool * isValid) const {
00304 Identifier id;
00305 int stationName = stationNameIndex(stationNameStr);
00306 id = padID(stationName, stationEta, stationPhi, multilayer, gasGap, channelType, padEta, padPhi, check, isValid);
00307 return id;
00308 }
00309
00310 inline Identifier sTgcIdHelper::padID(const Identifier& id, int multilayer, int gasGap, int channelType, int padEta, int padPhi, bool check, bool* isValid) const {
00311 Identifier result(id);
00312 bool val = false;
00313 m_mplet_impl.pack (multilayer,result);
00314 m_gap_impl.pack (gasGap,result);
00315 m_typ_impl.pack (channelType,result);
00316 int channel = -1;
00317 if (channelType == Pad) {
00318 channel = (padPhi - 1) * PadEtaMax + padEta;
00319 } else {
00320 *isValid = false;
00321 }
00322 m_cha_impl.pack (channel,result);
00323 if ( check ) {
00324 val = this->valid(result);
00325 if ( isValid ) *isValid = val;
00326 }
00327 return result;
00328 }
00329
00330
00331 inline Identifier sTgcIdHelper::parentID(const Identifier& id) const {
00332 assert(is_stgc(id));
00333 Identifier result(id);
00334 m_mplet_impl.reset(result);
00335 m_gap_impl.reset(result);
00336 m_typ_impl.reset(result);
00337 m_cha_impl.reset(result);
00338 return result;
00339 }
00340
00341
00342 inline int sTgcIdHelper::multilayer(const Identifier& id) const {
00343 return m_mplet_impl.unpack(id);
00344 }
00345
00346
00347 inline int sTgcIdHelper::gasGap(const Identifier& id) const {
00348 return m_gap_impl.unpack(id);
00349 }
00350
00351 inline int sTgcIdHelper::channelType(const Identifier& id) const {
00352 return m_typ_impl.unpack(id);
00353 }
00354
00356 inline bool sTgcIdHelper::measuresPhi(const Identifier& id) const {
00357 return (channelType(id) == Strip) ? 0 : 1;
00358 }
00359
00360 inline int sTgcIdHelper::channel(const Identifier& id) const {
00361 return m_cha_impl.unpack(id);
00362 }
00363
00364
00365 inline int sTgcIdHelper::stationEtaMin() const {
00366 return StationEtaMin;
00367 }
00368
00369 inline int sTgcIdHelper::stationEtaMax() const {
00370 return StationEtaMax;
00371 }
00372
00373 inline int sTgcIdHelper::stationPhiMin() const {
00374 return StationPhiMin;
00375 }
00376
00377 inline int sTgcIdHelper::stationPhiMax() const {
00378 return StationPhiMax;
00379 }
00380
00381 inline int sTgcIdHelper::multilayerMin() const
00382 {
00383 return MultilayerMin;
00384 }
00385
00386 inline int sTgcIdHelper::multilayerMax() const
00387 {
00388 return MultilayerMax;
00389 }
00390
00391 inline int sTgcIdHelper::gasGapMin() const {
00392 return GasGapMin;
00393 }
00394
00395 inline int sTgcIdHelper::gasGapMax() const {
00396 return GasGapMax;
00397 }
00398
00399 inline int sTgcIdHelper::channelTypeMin() const {
00400 return ChannelTypeMin;
00401 }
00402
00403 inline int sTgcIdHelper::channelTypeMax() const {
00404 return ChannelTypeMax;
00405 }
00406
00407 inline int sTgcIdHelper::channelMin() const {
00408 return ChannelMin;
00409 }
00410
00411 inline int sTgcIdHelper::channelMax() const {
00412 return ChannelMax;
00413 }
00414
00415 inline int sTgcIdHelper::padEtaMin() const {
00416 return PadEtaMin;
00417 }
00418
00419 inline int sTgcIdHelper::padEtaMax() const {
00420 return PadEtaMax;
00421 }
00422
00423 inline int sTgcIdHelper::padPhiMin() const {
00424 return PadPhiMin;
00425 }
00426
00427 inline int sTgcIdHelper::padPhiMax() const {
00428 return PadPhiMax;
00429 }
00430
00432 inline int sTgcIdHelper::stgcTechnology() const
00433 {
00434 int stgcField = technologyIndex("STGC");
00435 if (m_dict)
00436 {
00437 stgcField = stgc_field_value();
00438 }
00439 return stgcField;
00440 }
00441
00442 inline bool sTgcIdHelper::LargeSector(int stationName) const {
00443 return ('L' == stationNameString(stationName)[2]);
00444 }
00445
00446 inline bool sTgcIdHelper::SmallSector(int stationName) const {
00447 return ('S' == stationNameString(stationName)[2]);
00448 }
00449
00450
00451 #endif // MUONIDHELPERS_STGCIDHELPER_H