00001
00002
00003
00004
00005
00006
00007 #ifndef MUONIDHELPERS_MMIDHELPER_H
00008 #define MUONIDHELPERS_MMIDHELPER_H
00009
00010
00011 class MsgStream;
00012 #include "MuonIdHelpers/MuonIdHelper.h"
00013
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 class MmIdHelper : public MuonIdHelper {
00054 public:
00055
00056
00057 MmIdHelper();
00058
00059
00060 virtual ~MmIdHelper();
00061
00063
00065 virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr);
00066 virtual int get_module_hash(const Identifier& id, IdentifierHash& hash_id ) const;
00067 virtual int get_detectorElement_hash(const Identifier& id, IdentifierHash& hash_id ) const;
00068
00070
00071
00072 Identifier elementID(int stationName, int stationEta, int stationPhi, bool check=false, bool* isValid=0) const;
00073 Identifier elementID(std::string stationNameStr, int stationEta, int stationPhi, bool check=false, bool* isValid=0) const ;
00074 Identifier elementID(const Identifier& channelID) const ;
00075
00076 Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel, bool check=false, bool* isValid=0) const ;
00077 Identifier channelID(std::string stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channel, bool check=false, bool* isValid=0) const ;
00078 Identifier channelID(const Identifier& id, int multilayer, int gasGap, int channel, bool check=false, bool* isValid=0) const ;
00079
00080 Identifier parentID (const Identifier& id) const;
00081
00082 Identifier multilayerID(const Identifier& channeldID) const;
00083 Identifier multilayerID(const Identifier& moduleID, int multilayer, bool check=false, bool* isValid=0) const;
00084
00085
00086
00087 void idChannels (const Identifier& id, std::vector<Identifier>& vect) const;
00088
00089
00090 int gasGap(const Identifier& id) const;
00091 int multilayer(const Identifier& id) const;
00092 int channel(const Identifier& id) const;
00093 bool measuresPhi(const Identifier& id) const;
00094
00095 int numberOfMultilayers(const Identifier& id) const;
00096
00097
00098
00099 int stationEtaMin() const;
00100 int stationEtaMax() const;
00101 int stationPhiMin() const;
00102 int stationPhiMax() const;
00103 int multilayerMin() const;
00104 int multilayerMax() const;
00105 int gasGapMin() const;
00106 int gasGapMax() const;
00107 int channelMin() const;
00108 int channelMax() const;
00109
00110
00111 int stationEtaMin (const Identifier& id) const;
00112 int stationEtaMax (const Identifier& id) const;
00113 int stationPhiMin (const Identifier& id) const;
00114 int stationPhiMax (const Identifier& id) const;
00115 int multilayerMin(const Identifier& id) const;
00116 int multilayerMax(const Identifier& id) const;
00117 int gasGapMin (const Identifier& id) const;
00118 int gasGapMax (const Identifier& id) const;
00119 int channelMin (const Identifier& id) const;
00120 int channelMax (const Identifier& id) const;
00121
00122
00123 int sectorType(std::string stationName, int stationEta) const;
00124 int sectorType(int stationName, int stationEta) const;
00125
00126
00127 bool valid(const Identifier& id) const;
00128 bool validElement(const Identifier& id) const;
00129
00130 private:
00131 int init_id_to_hashes();
00132 unsigned int m_module_hashes[60][20][48];
00133 unsigned int m_detectorElement_hashes[60][20][8][3];
00134
00135
00136 size_type m_GASGAP_INDEX;
00137
00138 IdDictFieldImplementation m_mplet_impl;
00139 IdDictFieldImplementation m_gap_impl;
00140 IdDictFieldImplementation m_cha_impl;
00141
00142
00143 bool validElement(const Identifier& id, int stationName, int stationEta, int stationPhi) const;
00144 bool validChannel(const Identifier& id, int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const;
00145
00146
00147 int mmTechnology() const;
00148 bool LargeSector(int stationName) const;
00149 bool SmallSector(int stationName) const;
00150
00151
00152 enum MmIndices {
00153 MultilayerIndex = 5,
00154 GasGapIndex = 6,
00155 ChannelIndex = 7
00156 };
00157
00158
00159 enum MmRanges {
00160 StationEtaMin = 0,
00161 StationEtaMax = 3,
00162 StationPhiMin = 1,
00163 StationPhiMax = 8,
00164 MultilayerMin = 1,
00165 MultilayerMax = 2,
00166 GasGapMin = 1,
00167 GasGapMax = 4,
00168 ChannelMin = 1,
00169 ChannelMax = 200
00170 };
00171
00172 inline virtual void create_mlog() const;
00173 };
00174
00175
00176 typedef MmIdHelper MM_ID;
00177
00178 CLASS_DEF(MmIdHelper, 4175, 1)
00179
00180
00181 inline Identifier MmIdHelper::elementID(int stationName, int stationEta, int stationPhi, bool check, bool* isValid) const {
00182
00183 Identifier result((Identifier::value_type)0);
00184 bool val = false;
00185 m_muon_impl.pack(muon_field_value(),result);
00186 m_sta_impl.pack (stationName,result);
00187 m_eta_impl.pack (stationEta,result);
00188 m_phi_impl.pack (stationPhi,result);
00189 m_tec_impl.pack (mm_field_value(),result);
00190 if ( check ) {
00191 val = this->validElement(result,stationName,stationEta,stationPhi);
00192 if ( isValid ) *isValid = val;
00193 }
00194 return result;
00195 }
00196
00197 inline Identifier MmIdHelper::elementID(std::string stationNameStr, int stationEta, int stationPhi, bool check, bool* isValid) const {
00198 Identifier id;
00199 int stationName = stationNameIndex(stationNameStr);
00200 id = elementID(stationName, stationEta, stationPhi, check, isValid);
00201 return id;
00202 }
00203
00204 inline Identifier MmIdHelper::elementID(const Identifier& id) const {
00205 return parentID(id);
00206 }
00207
00208 inline Identifier MmIdHelper::channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel, bool check, bool* isValid) const {
00209
00210 Identifier result((Identifier::value_type)0);
00211 bool val = false;
00212 m_muon_impl.pack(muon_field_value(),result);
00213 m_sta_impl.pack (stationName,result);
00214 m_eta_impl.pack (stationEta,result);
00215 m_phi_impl.pack (stationPhi,result);
00216 m_tec_impl.pack (mm_field_value(),result);
00217 m_mplet_impl.pack (multilayer,result);
00218 m_gap_impl.pack (gasGap,result);
00219 m_cha_impl.pack (channel,result);
00220 if ( check ) {
00221 val = validChannel(result,stationName,stationEta,stationPhi,multilayer,gasGap,channel);
00222 if ( isValid ) *isValid = val;
00223 }
00224 return result;
00225 }
00226
00227 inline Identifier MmIdHelper::channelID(std::string stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channel, bool check, bool * isValid) const {
00228 Identifier id;
00229 int stationName = stationNameIndex(stationNameStr);
00230 id = channelID(stationName, stationEta, stationPhi, multilayer, gasGap, channel, check, isValid);
00231 return id;
00232 }
00233
00234 inline Identifier MmIdHelper::channelID(const Identifier& id, int multilayer, int gasGap, int channel, bool check, bool* isValid) const {
00235 Identifier result(id);
00236 bool val = false;
00237 m_mplet_impl.pack (multilayer,result);
00238 m_gap_impl.pack (gasGap,result);
00239 m_cha_impl.pack (channel,result);
00240 if ( check ) {
00241 val = this->valid(result);
00242 if ( isValid ) *isValid = val;
00243 }
00244 return result;
00245 }
00246
00247
00248 inline Identifier MmIdHelper::parentID(const Identifier& id) const {
00249 assert(is_mm(id));
00250 Identifier result(id);
00251 m_mplet_impl.reset(result);
00252 m_gap_impl.reset(result);
00253 m_cha_impl.reset(result);
00254 return result;
00255 }
00256
00257
00258 inline int MmIdHelper::multilayer(const Identifier& id) const
00259 {
00260 return m_mplet_impl.unpack(id);
00261 }
00262
00263 inline int MmIdHelper::gasGap(const Identifier& id) const {
00264 return m_gap_impl.unpack(id);
00265 }
00266
00267 inline int MmIdHelper::channel(const Identifier& id) const {
00268 return m_cha_impl.unpack(id);
00269 }
00270
00271
00272 inline int MmIdHelper::stationEtaMin() const {
00273 return StationEtaMin;
00274 }
00275
00276 inline int MmIdHelper::stationEtaMax() const {
00277 return StationEtaMax;
00278 }
00279
00280 inline int MmIdHelper::stationPhiMin() const {
00281 return StationPhiMin;
00282 }
00283
00284 inline int MmIdHelper::stationPhiMax() const {
00285 return StationPhiMax;
00286 }
00287
00288 inline int MmIdHelper::multilayerMin() const
00289 {
00290 return MultilayerMin;
00291 }
00292
00293 inline int MmIdHelper::multilayerMax() const
00294 {
00295 return MultilayerMax;
00296 }
00297
00298 inline int MmIdHelper::gasGapMin() const {
00299 return GasGapMin;
00300 }
00301
00302 inline bool MmIdHelper::measuresPhi(const Identifier& ) const{
00303 return false;
00304 }
00305
00306 inline int MmIdHelper::gasGapMax() const {
00307 return GasGapMax;
00308 }
00309
00310 inline int MmIdHelper::channelMin() const {
00311 return ChannelMin;
00312 }
00313
00314 inline int MmIdHelper::channelMax() const {
00315 return ChannelMax;
00316 }
00317
00319 inline int MmIdHelper::mmTechnology() const
00320 {
00321 int mmField = technologyIndex("MM");
00322 if (m_dict)
00323 {
00324 mmField = mm_field_value();
00325 }
00326 return mmField;
00327 }
00328
00329 inline bool MmIdHelper::LargeSector(int stationName) const {
00330 return ('L' == stationNameString(stationName)[2]);
00331 }
00332
00333 inline bool MmIdHelper::SmallSector(int stationName) const {
00334 return ('S' == stationNameString(stationName)[2]);
00335 }
00336
00337
00338 inline int MmIdHelper::sectorType(std::string stationName, int stationEta) const {
00339 if ('L' == stationName[2]) { return (abs(stationEta) + 1 ); }
00340 else if ('S' == stationName[2]) { return (abs(stationEta) + 12 ); }
00341 assert(0);
00342 return -1;
00343 }
00344
00345 inline int MmIdHelper::sectorType(int stationName, int stationEta) const {
00346 std::string name = stationNameString(stationName);
00347 return sectorType(name, stationEta);
00348 }
00349
00350 #endif // MUONIDHELPERS_MMIDHELPER_H