00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef MUONIDHELPERS_TGCIDHELPER_H
00011 #define MUONIDHELPERS_TGCIDHELPER_H
00012
00013
00014 class MsgStream;
00015 #include "MuonIdHelpers/MuonIdHelper.h"
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
00055
00056
00057 class TgcIdHelper : public MuonIdHelper
00058 {
00059 public:
00060
00061
00062
00063 TgcIdHelper();
00064
00065
00066
00067 virtual ~TgcIdHelper();
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, bool check=false, bool* isValid=0) const;
00083 Identifier elementID(std::string stationNameStr, int stationEta,
00084 int stationPhi, bool check=false, bool* isValid=0) const ;
00085 Identifier elementID(const Identifier& channelID) const ;
00086 Identifier channelID(int stationName, int stationEta, int stationPhi,
00087 int gasGap, int isStrip, int channel, bool check=false, bool* isValid=0) const ;
00088 Identifier channelID(std::string stationNameStr, int stationEta,
00089 int stationPhi, int gasGap, int isStrip, int channel, bool check=false, bool* isValid=0) const ;
00090 Identifier channelID(const Identifier& id, int gasGap, int isStrip,
00091 int channel, bool check=false, bool* isValid=0) const ;
00092
00093 Identifier parentID (const Identifier& id) const;
00094
00095
00096 void idChannels (const Identifier& id, std::vector<Identifier>& vect) const;
00097
00098
00099
00100 int gasGap(const Identifier& id) const;
00101
00103 int isStrip(const Identifier& id) const;
00104 bool measuresPhi(const Identifier& id) const;
00105
00106 int channel(const Identifier& id) const;
00107
00108
00109
00110
00111 int stationEtaMin() const;
00112 int stationEtaMax() const;
00113 int stationPhiMin(bool endcap) const;
00114 int stationPhiMax(bool endcap) const;
00115 int gasGapMin() const;
00116 int gasGapMax(bool triplet) const;
00117 int isStripMin() const;
00118 int isStripMax() const;
00119 int channelMin() const;
00120 int channelMax() const;
00121
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 gasGapMin (const Identifier& id) const;
00130 int gasGapMax (const Identifier& id) const;
00131 int isStripMin (const Identifier& id) const;
00132 int isStripMax (const Identifier& id) const;
00133 int channelMin (const Identifier& id) const;
00134 int channelMax (const Identifier& id) const;
00135
00136
00137
00138 int chamberType(std::string stationName, int stationEta) const;
00139 int chamberType(int stationName, int stationEta) const;
00140
00141
00142
00143 bool valid(const Identifier& id) const;
00144 bool validElement(const Identifier& id) const;
00145
00146 private:
00147
00148 int init_id_to_hashes();
00149 unsigned int m_module_hashes[60][20][48];
00150
00151
00152 size_type m_GASGAP_INDEX;
00153 size_type m_ISSTRIP_INDEX;
00154
00155 IdDictFieldImplementation m_gap_impl;
00156 IdDictFieldImplementation m_ist_impl;
00157 IdDictFieldImplementation m_cha_impl;
00158
00159
00160
00161 bool validElement(const Identifier& id, int stationName, int stationEta,
00162 int stationPhi) const;
00163 bool validChannel(const Identifier& id, int stationName, int stationEta,
00164 int stationPhi,int gasGap, int isStrip,
00165 int channel) const;
00166
00167
00168
00169 int tgcTechnology() const;
00170 bool endcapChamber(int stationName) const;
00171 bool tripletChamber(int stationName) const;
00172
00173
00174
00175 enum TgcIndices
00176 {
00177 GasGapIndex = 5,
00178 IsStripIndex = 6,
00179 ChannelIndex = 7
00180 };
00181
00182
00183
00184 enum TgcRanges
00185 {
00186 StationEtaMin = -8,
00187 StationEtaMax = 8,
00188 StationPhiEndcapMin = 1,
00189 StationPhiEndcapMax = 48,
00190 StationPhiForwardMin = 1,
00191 StationPhiForwardMax = 24,
00192 GasGapMin = 1,
00193 GasGapDoubletMax = 2,
00194 GasGapTripletMax = 3,
00195 IsStripMin = 0,
00196 IsStripMax = 1,
00197 ChannelMin = 1,
00198 ChannelMax = 135
00199 };
00200 inline virtual void create_mlog() const;
00201 };
00202
00203
00204
00205 typedef TgcIdHelper TGC_ID;
00206
00207 CLASS_DEF(TgcIdHelper, 4173, 1)
00208
00209
00210
00211 inline Identifier TgcIdHelper::elementID(int stationName, int stationEta, int stationPhi,
00212 bool check, bool* isValid) const {
00213
00214 Identifier result((Identifier::value_type)0);
00215 bool val = false;
00216 m_muon_impl.pack(muon_field_value(),result);
00217 m_sta_impl.pack (stationName,result);
00218 m_eta_impl.pack (stationEta,result);
00219 m_phi_impl.pack (stationPhi,result);
00220 m_tec_impl.pack (tgc_field_value(),result);
00221 if ( check ) {
00222 val = this->validElement(result,stationName,stationEta,stationPhi);
00223 if ( isValid ) *isValid = val;
00224 }
00225 return result;
00226 }
00227
00228 inline Identifier TgcIdHelper::elementID(std::string stationNameStr, int stationEta,
00229 int stationPhi, bool check, bool* isValid) const {
00230
00231 Identifier id;
00232 int stationName = stationNameIndex(stationNameStr);
00233 id = elementID(stationName, stationEta, stationPhi, check, isValid);
00234 return id;
00235 }
00236
00237 inline Identifier TgcIdHelper::elementID(const Identifier& id) const {
00238
00239 return parentID(id);
00240 }
00241
00242 inline Identifier TgcIdHelper::channelID(int stationName, int stationEta, int stationPhi,
00243 int gasGap, int isStrip, int channel, bool check, bool* isValid) const {
00244
00245 Identifier result((Identifier::value_type)0);
00246 bool val = false;
00247 m_muon_impl.pack(muon_field_value(),result);
00248 m_sta_impl.pack (stationName,result);
00249 m_eta_impl.pack (stationEta,result);
00250 m_phi_impl.pack (stationPhi,result);
00251 m_tec_impl.pack (tgc_field_value(),result);
00252 m_gap_impl.pack (gasGap,result);
00253 m_ist_impl.pack (isStrip,result);
00254 m_cha_impl.pack (channel,result);
00255 if ( check ) {
00256 val = validChannel(result,stationName,stationEta,stationPhi,
00257 gasGap,isStrip,channel);
00258 if ( isValid ) *isValid = val;
00259 }
00260 return result;
00261 }
00262
00263 inline Identifier TgcIdHelper::channelID(std::string stationNameStr, int stationEta,
00264 int stationPhi, int gasGap, int isStrip,
00265 int channel, bool check, bool * isValid) const {
00266 Identifier id;
00267 int stationName = stationNameIndex(stationNameStr);
00268 id = channelID(stationName, stationEta, stationPhi, gasGap, isStrip, channel, check, isValid);
00269 return id;
00270 }
00271
00272 inline Identifier TgcIdHelper::channelID(const Identifier& id,
00273 int gasGap, int isStrip, int channel, bool check, bool* isValid) const {
00274
00275 Identifier result(id);
00276 bool val = false;
00277 m_gap_impl.pack (gasGap,result);
00278 m_ist_impl.pack (isStrip,result);
00279 m_cha_impl.pack (channel,result);
00280 if ( check ) {
00281 val = this->valid(result);
00282 if ( isValid ) *isValid = val;
00283 }
00284 return result;
00285
00286 }
00287
00288
00289 inline Identifier TgcIdHelper::parentID(const Identifier& id) const {
00290 assert(is_tgc(id));
00291 Identifier result(id);
00292 m_gap_impl.reset(result);
00293 m_ist_impl.reset(result);
00294 m_cha_impl.reset(result);
00295 return result;
00296 }
00297
00298
00299
00300 inline int TgcIdHelper::gasGap(const Identifier& id) const {
00301
00302 return m_gap_impl.unpack(id);
00303 }
00304
00306 inline int TgcIdHelper::isStrip(const Identifier& id) const {
00307
00308 return m_ist_impl.unpack(id);
00309 }
00310
00311 inline bool TgcIdHelper::measuresPhi(const Identifier& id) const {
00312
00313 return isStrip(id);
00314 }
00315
00316 inline int TgcIdHelper::channel(const Identifier& id) const {
00317
00318 return m_cha_impl.unpack(id);
00319 }
00320
00321
00322
00323 inline int TgcIdHelper::stationEtaMin() const
00324 {
00325 return StationEtaMin;
00326 }
00327
00328 inline int TgcIdHelper::stationEtaMax() const
00329 {
00330 return StationEtaMax;
00331 }
00332
00333 inline int TgcIdHelper::stationPhiMin(bool endcap) const
00334 {
00335 if (endcap)
00336 {
00337 return StationPhiEndcapMin;
00338 }
00339 else
00340 {
00341 return StationPhiForwardMin;
00342 }
00343 }
00344
00345 inline int TgcIdHelper::stationPhiMax(bool endcap) const
00346 {
00347 if (endcap)
00348 {
00349 return StationPhiEndcapMax;
00350 }
00351 else
00352 {
00353 return StationPhiForwardMax;
00354 }
00355 }
00356
00357 inline int TgcIdHelper::gasGapMin() const
00358 {
00359 return GasGapMin;
00360 }
00361
00362 inline int TgcIdHelper::gasGapMax(bool triplet) const
00363 {
00364 if (triplet)
00365 {
00366 return GasGapTripletMax;
00367 }
00368 else
00369 {
00370 return GasGapDoubletMax;
00371 }
00372 }
00373
00374 inline int TgcIdHelper::isStripMin() const
00375 {
00376 return IsStripMin;
00377 }
00378
00379 inline int TgcIdHelper::isStripMax() const
00380 {
00381 return IsStripMax;
00382 }
00383
00384 inline int TgcIdHelper::channelMin() const
00385 {
00386 return ChannelMin;
00387 }
00388
00389 inline int TgcIdHelper::channelMax() const
00390 {
00391 return ChannelMax;
00392 }
00394
00395 inline int TgcIdHelper::tgcTechnology() const
00396 {
00397 int tgcField = technologyIndex("TGC");
00398 if (m_dict)
00399 {
00400 tgcField = tgc_field_value();
00401 }
00402 return tgcField;
00403 }
00404
00405 inline bool TgcIdHelper::endcapChamber(int stationName) const
00406 {
00407 std::string name = stationNameString(stationName);
00408 return ('E' == stationNameString(stationName)[2]);
00409 }
00410
00411 inline bool TgcIdHelper::tripletChamber(int stationName) const
00412 {
00413 std::string name = stationNameString(stationName);
00414 return ('1' == name[1]);
00415 }
00416
00417 inline int TgcIdHelper::chamberType(std::string stationName, int stationEta) const
00418 {
00419 if ('1' == stationName[1])
00420 {
00421 if ('F' == stationName[2]) return 1;
00422 else return (abs(stationEta) + 1);
00423 }
00424 else if ('2' == stationName[1])
00425 {
00426 if ('F' == stationName[2]) return 6;
00427 else return (abs(stationEta) + 6);
00428 }
00429 else if ('3' == stationName[1])
00430 {
00431 if ('F' == stationName[2]) return 12;
00432 else return (abs(stationEta) + 12);
00433 }
00434 else if ('4' == stationName[1])
00435 {
00436 if ('F' == stationName[2]) return 18;
00437 else return (abs(stationEta) + 18);
00438 }
00439 assert(0);
00440 return -1;
00441 }
00442
00443 inline int TgcIdHelper::chamberType(int stationName, int stationEta) const {
00444
00445 std::string name = stationNameString(stationName);
00446 return chamberType(name, stationEta);
00447 }
00448
00449 #endif // MUONIDHELPERS_TGCIDHELPER_H
00450