00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef MUONIDHELPERS_MDTIDHELPER_H
00011 #define MUONIDHELPERS_MDTIDHELPER_H
00012
00013
00014
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
00058 class MdtIdHelper : public MuonIdHelper
00059 {
00060 public:
00061
00062
00063
00064
00065 MdtIdHelper();
00066
00067
00068
00069 virtual ~MdtIdHelper();
00070
00071
00073
00075 virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr);
00076 virtual int get_module_hash(const Identifier& id, IdentifierHash& hash_id ) const;
00077 virtual int get_detectorElement_hash (const Identifier& id, IdentifierHash& hash_id ) const;
00078
00080
00081
00082
00083 Identifier elementID(int stationName, int stationEta, int stationPhi, bool check=false, bool* isValid=0) const;
00084 Identifier elementID(std::string stationNameStr, int stationEta, 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, int multilayer, int tubeLayer, int tube, bool check=false, bool* isValid=0) const;
00087 Identifier channelID(std::string stationNameStr, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube, bool check=false, bool* isValid=0) const;
00088 Identifier channelID(const Identifier& id, int multilayer, int tubeLayer, int tube, bool check=false, bool* isValid=0) const;
00089
00090 Identifier parentID (const Identifier& id) const;
00091
00092 Identifier multilayerID(const Identifier& channeldID) const;
00093 Identifier multilayerID(const Identifier& moduleID, int multilayer, bool check=false, bool* isValid=0) const;
00094
00095
00096 void idChannels (const Identifier& id, std::vector<Identifier>& vect) const;
00097
00098
00099
00100 int channel(const Identifier& id) const;
00101
00102 int multilayer(const Identifier& id) const;
00103 int tubeLayer (const Identifier& id) const;
00104 int tube (const Identifier& id) const;
00105
00106 int numberOfMultilayers(const Identifier& id) const;
00107
00108
00109
00110 int stationEtaMin(bool barrel) const;
00111 int stationEtaMax(bool barrel) const;
00112 int stationPhiMin() const;
00113 int stationPhiMax() const;
00114 int multilayerMin() const;
00115 int multilayerMax() const;
00116 int tubeLayerMin() const;
00117 int tubeLayerMax() const;
00118 int tubeMin() const;
00119 int tubeMax() const;
00120
00121
00122
00123 int stationEtaMin(const Identifier& id) const;
00124 int stationEtaMax(const Identifier& id) const;
00125 int stationPhiMin(const Identifier& id) const;
00126 int stationPhiMax(const Identifier& id) const;
00127 int multilayerMin(const Identifier& id) const;
00128 int multilayerMax(const Identifier& id) const;
00129 int tubeLayerMin (const Identifier& id) const;
00130 int tubeLayerMax (const Identifier& id) const;
00131 int tubeMin (const Identifier& id) const;
00132 int tubeMax (const Identifier& id) const;
00133
00134
00135
00136 bool valid(const Identifier& id) const;
00137 bool validElement(const Identifier& id) const;
00138
00139
00141 int gasGap(const Identifier& id) const;
00143 bool measuresPhi(const Identifier& id) const;
00144
00145 private:
00146
00147 int init_id_to_hashes();
00148 unsigned int m_module_hashes[60][20][8];
00149 unsigned int m_detectorElement_hashes[60][20][8][3];
00150
00151
00152 size_type m_TUBELAYER_INDEX;
00153
00154 IdDictFieldImplementation m_mla_impl;
00155 IdDictFieldImplementation m_lay_impl;
00156 IdDictFieldImplementation m_tub_impl;
00157
00158
00159
00160 bool validElement(const Identifier& id, int stationName, int stationEta, int stationPhi) const;
00161 bool validChannel(const Identifier& id, int stationName, int stationEta, int stationPhi,int multilayer, int tubeLayer, int tube) const;
00162
00163
00164
00165 int mdtTechnology() const;
00166 bool barrelChamber(int stationName) const;
00167
00168
00169
00170 enum MdtIndices
00171 {
00172 MultilayerIndex = 5,
00173 TubeLayerIndex = 6,
00174 TubeIndex = 7
00175 };
00176
00177
00178
00179 enum MdtRanges
00180 {
00181 StationEtaBarrelMin = -8,
00182 StationEtaBarrelMax = 8,
00183 StationEtaEndcapMin = -6,
00184 StationEtaEndcapMax = 6,
00185 StationPhiMin = 1,
00186 StationPhiMax = 8,
00187 MultilayerMin = 1,
00188 MultilayerMax = 2,
00189 TubeLayerMin = 1,
00190 TubeLayerMax = 4,
00191 TubeMin = 1,
00192 TubeMax = 78
00193 };
00194 inline virtual void create_mlog() const;
00195 };
00196
00197
00198
00199 typedef MdtIdHelper MDT_ID;
00200
00201 CLASS_DEF(MdtIdHelper, 4170, 1)
00202
00203
00204
00205 inline Identifier MdtIdHelper::elementID(int stationName,
00206 int stationEta, int stationPhi, bool check, bool* isValid) const
00207 {
00208
00209 Identifier result((Identifier::value_type)0);
00210 bool val = false;
00211 m_muon_impl.pack(muon_field_value(),result);
00212 m_sta_impl.pack (stationName,result);
00213 m_eta_impl.pack (stationEta,result);
00214 m_phi_impl.pack (stationPhi,result);
00215 m_tec_impl.pack (mdt_field_value(),result);
00216 if ( check ) {
00217 val = this->validElement(result, stationName, stationEta, stationPhi);
00218 if ( isValid ) *isValid = val;
00219 }
00220 return result;
00221 }
00222
00223 inline Identifier MdtIdHelper::elementID(std::string stationNameStr,
00224 int stationEta, int stationPhi, bool check, bool* isValid) const
00225 {
00226 Identifier id;
00227 int stationName = stationNameIndex(stationNameStr);
00228 id = elementID(stationName, stationEta, stationPhi, check, isValid);
00229 return id;
00230 }
00231
00232 inline Identifier MdtIdHelper::elementID(const Identifier& id) const
00233 {
00234 return parentID(id);
00235 }
00236
00237 inline Identifier MdtIdHelper::channelID(int stationName,
00238 int stationEta, int stationPhi,
00239 int multilayer, int tubeLayer, int tube,
00240 bool check, bool* isValid) const
00241 {
00242
00243
00244 Identifier result((Identifier::value_type)0);
00245 bool val = false;
00246 m_muon_impl.pack(muon_field_value(),result);
00247 m_sta_impl.pack (stationName,result);
00248 m_eta_impl.pack (stationEta,result);
00249 m_phi_impl.pack (stationPhi,result);
00250 m_tec_impl.pack (mdt_field_value(),result);
00251 m_mla_impl.pack (multilayer,result);
00252 m_lay_impl.pack (tubeLayer,result);
00253 m_tub_impl.pack (tube,result);
00254 if ( check ) {
00255 val = this->validChannel(result, stationName, stationEta, stationPhi,
00256 multilayer, tubeLayer, tube);
00257 if ( isValid ) *isValid = val;
00258 }
00259 return result;
00260 }
00261
00262 inline Identifier MdtIdHelper::channelID(std::string stationNameStr,
00263 int stationEta, int stationPhi,
00264 int multilayer, int tubeLayer, int tube,
00265 bool check, bool* isValid) const
00266 {
00267 Identifier id;
00268 int stationName = stationNameIndex(stationNameStr);
00269 id = channelID(stationName, stationEta, stationPhi, multilayer,
00270 tubeLayer, tube, check, isValid);
00271 return id;
00272 }
00273
00274 inline Identifier MdtIdHelper::channelID(const Identifier& id,
00275 int multilayer, int tubeLayer, int tube,
00276 bool check, bool* isValid) const
00277 {
00278 Identifier result(id);
00279 bool val = false;
00280 m_mla_impl.pack (multilayer,result);
00281 m_lay_impl.pack (tubeLayer,result);
00282 m_tub_impl.pack (tube,result);
00283 if ( check ) {
00284 val = this->valid(result);
00285 if ( isValid ) *isValid = val;
00286 }
00287 return result;
00288 }
00289
00291
00292 inline Identifier MdtIdHelper::parentID(const Identifier& id) const
00293 {
00294 assert(is_mdt(id));
00295 Identifier result(id);
00296 m_mla_impl.reset(result);
00297 m_lay_impl.reset(result);
00298 m_tub_impl.reset(result);
00299 return result;
00300 }
00301
00303
00304 inline int MdtIdHelper::multilayer(const Identifier& id) const
00305 {
00306
00307 return m_mla_impl.unpack(id);
00308
00309 }
00310
00311 inline int MdtIdHelper::tubeLayer(const Identifier& id) const
00312 {
00313
00314 return m_lay_impl.unpack(id);
00315
00316 }
00317
00318 inline int MdtIdHelper::tube(const Identifier& id) const
00319 {
00320
00321 return m_tub_impl.unpack(id);
00322
00323 }
00324
00325 inline int MdtIdHelper::gasGap(const Identifier& id) const
00326 {
00327
00328 return tubeLayer(id);
00329
00330 }
00331
00332 inline bool MdtIdHelper::measuresPhi(const Identifier& ) const
00333 {
00334
00335 return false;
00336
00337 }
00338
00339
00340 inline int MdtIdHelper::channel(const Identifier& id) const
00341 {
00342
00343 return tube(id);
00344
00345 }
00346
00348
00349 inline int MdtIdHelper::stationEtaMin(bool barrel) const
00350 {
00351 if (barrel)
00352 {
00353 return StationEtaBarrelMin;
00354 }
00355 else
00356 {
00357 return StationEtaEndcapMin;
00358 }
00359 }
00360
00361 inline int MdtIdHelper::stationEtaMax(bool barrel) const
00362 {
00363 if (barrel)
00364 {
00365 return StationEtaBarrelMax;
00366 }
00367 else
00368 {
00369 return StationEtaEndcapMax;
00370 }
00371 }
00372
00373 inline int MdtIdHelper::stationPhiMin() const
00374 {
00375 return StationPhiMin;
00376 }
00377
00378 inline int MdtIdHelper::stationPhiMax() const
00379 {
00380 return StationPhiMax;
00381 }
00382
00383 inline int MdtIdHelper::multilayerMin() const
00384 {
00385 return MultilayerMin;
00386 }
00387
00388 inline int MdtIdHelper::multilayerMax() const
00389 {
00390 return MultilayerMax;
00391 }
00392
00393 inline int MdtIdHelper::tubeLayerMin() const
00394 {
00395 return TubeLayerMin;
00396 }
00397
00398 inline int MdtIdHelper::tubeLayerMax() const
00399 {
00400 return TubeLayerMax;
00401 }
00402
00403 inline int MdtIdHelper::tubeMin() const
00404 {
00405 return TubeMin;
00406 }
00407
00408 inline int MdtIdHelper::tubeMax() const
00409 {
00410 return TubeMax;
00411 }
00413
00414 inline int MdtIdHelper::mdtTechnology() const
00415 {
00416
00417 int mdtField = technologyIndex("MDT");
00418 if (m_dict)
00419 {
00420 mdtField = mdt_field_value();
00421 }
00422 return mdtField;
00423 }
00424
00425 #endif // MUONIDHELPERS_MDTIDHELPER_H
00426
00427